瀏覽代碼

posix_acl: fix reference leaks in posix_acl_create

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>
Omar Sandoval 10 年之前
父節點
當前提交
fed0b588be
共有 1 個文件被更改,包括 9 次插入5 次删除
  1. 9 5
      fs/posix_acl.c

+ 9 - 5
fs/posix_acl.c

@@ -564,13 +564,11 @@ posix_acl_create(struct inode *dir, umode_t *mode,
 
 
 	*acl = posix_acl_clone(p, GFP_NOFS);
 	*acl = posix_acl_clone(p, GFP_NOFS);
 	if (!*acl)
 	if (!*acl)
-		return -ENOMEM;
+		goto no_mem;
 
 
 	ret = posix_acl_create_masq(*acl, mode);
 	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) {
 	if (ret == 0) {
 		posix_acl_release(*acl);
 		posix_acl_release(*acl);
@@ -591,6 +589,12 @@ no_acl:
 	*default_acl = NULL;
 	*default_acl = NULL;
 	*acl = NULL;
 	*acl = NULL;
 	return 0;
 	return 0;
+
+no_mem_clone:
+	posix_acl_release(*acl);
+no_mem:
+	posix_acl_release(p);
+	return -ENOMEM;
 }
 }
 EXPORT_SYMBOL_GPL(posix_acl_create);
 EXPORT_SYMBOL_GPL(posix_acl_create);