cxl_getfile(): fix double-iput() on alloc_file() failures
authorAl Viro <viro@zeniv.linux.org.uk>
Sat, 9 Jun 2018 13:43:13 +0000 (09:43 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Wed, 11 Jul 2018 03:29:03 +0000 (23:29 -0400)
Doing iput() after path_put() is wrong.

Cc: stable@vger.kernel.org
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
drivers/misc/cxl/api.c

index 753b1a698fc4e3ef74a7ebb718a1997ae8a13a4d..6b16946f9b05d45ea3372f955d12151bb2782cfd 100644 (file)
@@ -103,15 +103,15 @@ static struct file *cxl_getfile(const char *name,
        d_instantiate(path.dentry, inode);
 
        file = alloc_file(&path, OPEN_FMODE(flags), fops);
-       if (IS_ERR(file))
-               goto err_dput;
+       if (IS_ERR(file)) {
+               path_put(&path);
+               goto err_fs;
+       }
        file->f_flags = flags & (O_ACCMODE | O_NONBLOCK);
        file->private_data = priv;
 
        return file;
 
-err_dput:
-       path_put(&path);
 err_inode:
        iput(inode);
 err_fs: