]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
cgroup: don't put ERR_PTR() into fc->root
authorAl Viro <viro@zeniv.linux.org.uk>
Sun, 10 Nov 2019 16:53:27 +0000 (11:53 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 13 Dec 2019 07:48:30 +0000 (08:48 +0100)
[ Upstream commit 630faf81b3e61bcc90dc6d8b497800657d2752a5 ]

the caller of ->get_tree() expects NULL left there on error...

Reported-by: Thibaut Sautereau <thibaut@sautereau.fr>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/cgroup/cgroup.c

index 8be1da1ebd9a4f3d4ee3f6038a85e18e8d5fa685..f23862fa1514656fbf2d9f11a0ac0427bf38b5b2 100644 (file)
@@ -2119,11 +2119,12 @@ int cgroup_do_get_tree(struct fs_context *fc)
 
                nsdentry = kernfs_node_dentry(cgrp->kn, sb);
                dput(fc->root);
-               fc->root = nsdentry;
                if (IS_ERR(nsdentry)) {
-                       ret = PTR_ERR(nsdentry);
                        deactivate_locked_super(sb);
+                       ret = PTR_ERR(nsdentry);
+                       nsdentry = NULL;
                }
+               fc->root = nsdentry;
        }
 
        if (!ctx->kfc.new_sb_created)