pull unlock+dput() out into do_spu_create()
authorAl Viro <viro@zeniv.linux.org.uk>
Thu, 19 Jul 2012 12:23:13 +0000 (16:23 +0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Sun, 29 Jul 2012 17:24:13 +0000 (21:24 +0400)
... and cleaning spufs_create() a bit, while we are at it

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
arch/powerpc/platforms/cell/spufs/inode.c
arch/powerpc/platforms/cell/spufs/syscalls.c

index 0576c44aa75c92cb778414bb8f26d562cf78444e..dba1ce235da59e23172cd5d6474d9ce4a72900ac 100644 (file)
@@ -582,39 +582,32 @@ static struct file_system_type spufs_type;
 long spufs_create(struct path *path, struct dentry *dentry,
                unsigned int flags, umode_t mode, struct file *filp)
 {
+       struct inode *dir = path->dentry->d_inode;
        int ret;
 
-       ret = -EINVAL;
        /* check if we are on spufs */
        if (path->dentry->d_sb->s_type != &spufs_type)
-               goto out;
+               return -EINVAL;
 
        /* don't accept undefined flags */
        if (flags & (~SPU_CREATE_FLAG_ALL))
-               goto out;
+               return -EINVAL;
 
        /* only threads can be underneath a gang */
-       if (path->dentry != path->dentry->d_sb->s_root) {
-               if ((flags & SPU_CREATE_GANG) ||
-                   !SPUFS_I(path->dentry->d_inode)->i_gang)
-                       goto out;
-       }
+       if (path->dentry != path->dentry->d_sb->s_root)
+               if ((flags & SPU_CREATE_GANG) || !SPUFS_I(dir)->i_gang)
+                       return -EINVAL;
 
        mode &= ~current_umask();
 
        if (flags & SPU_CREATE_GANG)
-               ret = spufs_create_gang(path->dentry->d_inode,
-                                        dentry, path->mnt, mode);
+               ret = spufs_create_gang(dir, dentry, path->mnt, mode);
        else
-               ret = spufs_create_context(path->dentry->d_inode,
-                                           dentry, path->mnt, flags, mode,
+               ret = spufs_create_context(dir, dentry, path->mnt, flags, mode,
                                            filp);
        if (ret >= 0)
-               fsnotify_mkdir(path->dentry->d_inode, dentry);
+               fsnotify_mkdir(dir, dentry);
 
-out:
-       mutex_unlock(&path->dentry->d_inode->i_mutex);
-       dput(dentry);
        return ret;
 }
 
index 5665dcc382c7350208e5c2b084a0e94761ce5051..8591bb62d7fca91580ee30896ba22bd66d8a436d 100644 (file)
@@ -70,6 +70,8 @@ static long do_spu_create(const char __user *pathname, unsigned int flags,
        ret = PTR_ERR(dentry);
        if (!IS_ERR(dentry)) {
                ret = spufs_create(&path, dentry, flags, mode, neighbor);
+               mutex_unlock(&path.dentry->d_inode->i_mutex);
+               dput(dentry);
                path_put(&path);
        }