]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
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)
committerKhalid Elmously <khalid.elmously@canonical.com>
Wed, 6 Feb 2019 04:53:01 +0000 (04:53 +0000)
BugLink: http://bugs.launchpad.net/bugs/1812229
commit d202797f480c0e5918e7642d6716cdc62b3ab5c9 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/misc/cxl/api.c

index 7c11bad5cded29c64548556f871a5825f76639b3..82b94eb91c423a53701b993e09a3971934e720ea 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: