Skip to content

Commit

Permalink
[JFFS2] Add missing call to posix_acl_release
Browse files Browse the repository at this point in the history
posix_acl_clone does a memory allocation and sets a reference count, so
posix_acl_release is needed afterwards to free it.

The problem was fixed using the following semantic patch.
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@@
type T;
identifier E;
expression E1, E2;
int ret;
statement S;
@@

  T E;
  <+...
(
  E = \(posix_acl_clone\|posix_acl_alloc\|posix_acl_dup\)(...);
  if (E == NULL) S
|
  if ((E = \(posix_acl_clone\|posix_acl_alloc\|posix_acl_dup\)(...)) == NULL) S
)
  ... when != E2 = E
      when strict
(
  posix_acl_release(E);
|
  E1 = E;
|
+ posix_acl_release(E);
  return;
|
+ posix_acl_release(E);
  return ret;
)
  ...+>
// </smpl>

Signed-off-by: Julia Lawall <[email protected]>
Acked-by: KaiGai Kohei <[email protected]>
Signed-off-by: David Woodhouse <[email protected]>
  • Loading branch information
Julia Lawall authored and dwmw2 committed Jan 8, 2008
1 parent 71053fb commit 36f97bc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fs/jffs2/acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,10 @@ int jffs2_init_acl_pre(struct inode *dir_i, struct inode *inode, int *i_mode)
if (!clone)
return -ENOMEM;
rc = posix_acl_create_masq(clone, (mode_t *)i_mode);
if (rc < 0)
if (rc < 0) {
posix_acl_release(clone);
return rc;
}
if (rc > 0)
jffs2_iset_acl(inode, &f->i_acl_access, clone);

Expand Down

0 comments on commit 36f97bc

Please sign in to comment.