Skip to content

Commit

Permalink
posix_acl: fix reference leaks in posix_acl_create
Browse files Browse the repository at this point in the history
get_acl gets a reference which we must release in the error cases.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Omar Sandoval <osandov@osandov.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
osandov authored and Al Viro committed Feb 20, 2015
1 parent 76bf3f6 commit fed0b58
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions fs/posix_acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,13 +564,11 @@ posix_acl_create(struct inode *dir, umode_t *mode,

*acl = posix_acl_clone(p, GFP_NOFS);
if (!*acl)
return -ENOMEM;
goto no_mem;

ret = posix_acl_create_masq(*acl, mode);
if (ret < 0) {
posix_acl_release(*acl);
return -ENOMEM;
}
if (ret < 0)
goto no_mem_clone;

if (ret == 0) {
posix_acl_release(*acl);
Expand All @@ -591,6 +589,12 @@ posix_acl_create(struct inode *dir, umode_t *mode,
*default_acl = NULL;
*acl = NULL;
return 0;

no_mem_clone:
posix_acl_release(*acl);
no_mem:
posix_acl_release(p);
return -ENOMEM;
}
EXPORT_SYMBOL_GPL(posix_acl_create);

Expand Down

0 comments on commit fed0b58

Please sign in to comment.