cgroup: get the wrong css for css_alloc() during cgroup_init_subsys()
authorWei Yang <richard.weiyang@gmail.com>
Sat, 27 Nov 2021 14:59:19 +0000 (14:59 +0000)
committerTejun Heo <tj@kernel.org>
Mon, 29 Nov 2021 17:39:01 +0000 (07:39 -1000)
css_alloc() needs the parent css, while cgroup_css() gets current
cgropu's css. So we are getting the wrong css during
cgroup_init_subsys().

Fortunately, cgrp_dfl_root.cgrp's css is not set yet, so the value we
pass to css_alloc() is NULL anyway.

Let's pass NULL directly during init, since we know there is no parent
yet.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/cgroup/cgroup.c

index 919194de39c8328a40be3ba0157ecb644547d8c2..f522cee8e6506f6eb991f986da7b6907472b6ad2 100644 (file)
@@ -5711,7 +5711,7 @@ static void __init cgroup_init_subsys(struct cgroup_subsys *ss, bool early)
 
        /* Create the root cgroup state for this subsystem */
        ss->root = &cgrp_dfl_root;
-       css = ss->css_alloc(cgroup_css(&cgrp_dfl_root.cgrp, ss));
+       css = ss->css_alloc(NULL);
        /* We don't handle early failures gracefully */
        BUG_ON(IS_ERR(css));
        init_and_link_css(css, ss, &cgrp_dfl_root.cgrp);