From: Al Viro Date: Sun, 10 Nov 2019 16:53:27 +0000 (-0500) Subject: cgroup: don't put ERR_PTR() into fc->root X-Git-Tag: v5.4-rc8~20^2~5 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=630faf81b3e61bcc90dc6d8b497800657d2752a5;p=tomoyo%2Ftomoyo-test1.git cgroup: don't put ERR_PTR() into fc->root the caller of ->get_tree() expects NULL left there on error... Reported-by: Thibaut Sautereau Signed-off-by: Al Viro --- diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 080561bb8a4b..ef4242e5d4bc 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -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)