ANDROID: fix acl leaks
authorMark Salyzyn <salyzyn@google.com>
Mon, 23 Jan 2017 20:56:41 +0000 (12:56 -0800)
committerStricted <info@stricted.net>
Thu, 11 Oct 2018 16:03:55 +0000 (18:03 +0200)
Fixes regressions associated with commit
073931017b49d9458aa351605b43a7e34598caef

Signed-off-by: Mark Salyzyn <salyzyn@google.com>
Bug: 32458736
Change-Id: I6ee127dfdf3594d24ccd8560541ac554c5b05eb6

fs/gfs2/acl.c
fs/jfs/xattr.c
fs/xfs/xfs_acl.c

index e7b330ef4dfdaaaf636254f304051f3f442cf6e5..db243db44038b532ab1b01b4bd40ff2a0f67fed1 100644 (file)
@@ -268,8 +268,11 @@ static int gfs2_xattr_system_set(struct dentry *dentry, const char *name,
 
        if (type == ACL_TYPE_ACCESS) {
                umode_t mode = inode->i_mode;
+               struct posix_acl *old_acl = acl;
                error = posix_acl_update_mode(inode, &inode->i_mode, &acl);
 
+               if (!acl)
+                       posix_acl_release(old_acl);
                if (error)
                        goto out_release;
 
index c79b1d7a53e24be8c918313318b325b949997954..02bdfe007aa9f60b65b448682755a5021ae92fce 100644 (file)
@@ -693,8 +693,9 @@ static int can_set_system_xattr(struct inode *inode, const char *name,
                        return rc;
                }
                if (acl) {
+                       struct posix_acl *old_acl = acl;
                        rc = posix_acl_update_mode(inode, &inode->i_mode, &acl);
-                       posix_acl_release(acl);
+                       posix_acl_release(old_acl);
                        if (rc) {
                                printk(KERN_ERR
                                       "posix_acl_update_mode returned %d\n",
index 4f8e4770229cf78e0659e241aa11902a11b3609b..eaa2a3735519ec7cb4b34a3f2138e170310632c6 100644 (file)
@@ -389,7 +389,10 @@ xfs_xattr_acl_set(struct dentry *dentry, const char *name,
 
        if (type == ACL_TYPE_ACCESS) {
                umode_t mode = inode->i_mode;
+               struct posix_acl *old_acl = acl;
                error = posix_acl_update_mode(inode, &mode, &acl);
+               if (!acl)
+                       posix_acl_release(old_acl);
                if (error)
                        goto out_release;
                error = xfs_set_mode(inode, mode);