9p: close ACL leaks
[platform/adaptation/renesas_rcar/renesas_kernel.git] / fs / 9p / acl.c
index 535ab6e..7350f53 100644 (file)
@@ -96,12 +96,12 @@ static struct posix_acl *v9fs_get_cached_acl(struct inode *inode, int type)
        return acl;
 }
 
-int v9fs_check_acl(struct inode *inode, int mask, unsigned int flags)
+int v9fs_check_acl(struct inode *inode, int mask)
 {
        struct posix_acl *acl;
        struct v9fs_session_info *v9ses;
 
-       if (flags & IPERM_FLAG_RCU)
+       if (mask & MAY_NOT_BLOCK)
                return -ECHILD;
 
        v9ses = v9fs_inode2v9ses(inode);
@@ -185,12 +185,15 @@ int v9fs_acl_chmod(struct dentry *dentry)
 }
 
 int v9fs_set_create_acl(struct dentry *dentry,
-                       struct posix_acl *dpacl, struct posix_acl *pacl)
+                       struct posix_acl **dpacl, struct posix_acl **pacl)
 {
-       v9fs_set_acl(dentry, ACL_TYPE_DEFAULT, dpacl);
-       v9fs_set_acl(dentry, ACL_TYPE_ACCESS, pacl);
-       posix_acl_release(dpacl);
-       posix_acl_release(pacl);
+       if (dentry) {
+               v9fs_set_acl(dentry, ACL_TYPE_DEFAULT, *dpacl);
+               v9fs_set_acl(dentry, ACL_TYPE_ACCESS, *pacl);
+       }
+       posix_acl_release(*dpacl);
+       posix_acl_release(*pacl);
+       *dpacl = *pacl = NULL;
        return 0;
 }
 
@@ -212,11 +215,11 @@ int v9fs_acl_mode(struct inode *dir, mode_t *modep,
                struct posix_acl *clone;
 
                if (S_ISDIR(mode))
-                       *dpacl = acl;
+                       *dpacl = posix_acl_dup(acl);
                clone = posix_acl_clone(acl, GFP_NOFS);
-               retval = -ENOMEM;
+               posix_acl_release(acl);
                if (!clone)
-                       goto cleanup;
+                       return -ENOMEM;
 
                retval = posix_acl_create_masq(clone, &mode);
                if (retval < 0) {
@@ -225,11 +228,12 @@ int v9fs_acl_mode(struct inode *dir, mode_t *modep,
                }
                if (retval > 0)
                        *pacl = clone;
+               else
+                       posix_acl_release(clone);
        }
        *modep  = mode;
        return 0;
 cleanup:
-       posix_acl_release(acl);
        return retval;
 
 }