]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
ovl: fix creds leak in copy up error path
authorAmir Goldstein <amir73il@gmail.com>
Tue, 16 May 2017 05:45:46 +0000 (08:45 +0300)
committerMiklos Szeredi <mszeredi@redhat.com>
Thu, 18 May 2017 14:11:24 +0000 (16:11 +0200)
Fixes: 42f269b92540 ("ovl: rearrange code in ovl_copy_up_locked()")
Cc: <stable@vger.kernel.org> # v4.11
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/overlayfs/copy_up.c

index 9008ab9fbd2ebe89d419c249455eb740c48a9eb1..061a8448e6c438252c4134c3448f295f303bfeeb 100644 (file)
@@ -343,12 +343,13 @@ static int ovl_copy_up_locked(struct dentry *workdir, struct dentry *upperdir,
                temp = ovl_do_tmpfile(upperdir, stat->mode);
        else
                temp = ovl_lookup_temp(workdir, dentry);
-       err = PTR_ERR(temp);
-       if (IS_ERR(temp))
-               goto out1;
-
        err = 0;
-       if (!tmpfile)
+       if (IS_ERR(temp)) {
+               err = PTR_ERR(temp);
+               temp = NULL;
+       }
+
+       if (!err && !tmpfile)
                err = ovl_create_real(wdir, temp, &cattr, NULL, true);
 
        if (new_creds) {