Commit 3eb59ec6 authored by Li Zefan's avatar Li Zefan Committed by Tejun Heo

cgroup: fix a failure path in create_css()

If online_css() fails, we should remove cgroup files belonging
to css->ss.
Signed-off-by: default avatarLi Zefan <lizefan@huawei.com>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
parent 99afb0fd
...@@ -4112,17 +4112,17 @@ static int create_css(struct cgroup *cgrp, struct cgroup_subsys *ss) ...@@ -4112,17 +4112,17 @@ static int create_css(struct cgroup *cgrp, struct cgroup_subsys *ss)
err = percpu_ref_init(&css->refcnt, css_release); err = percpu_ref_init(&css->refcnt, css_release);
if (err) if (err)
goto err_free; goto err_free_css;
init_css(css, ss, cgrp); init_css(css, ss, cgrp);
err = cgroup_populate_dir(cgrp, 1 << ss->subsys_id); err = cgroup_populate_dir(cgrp, 1 << ss->subsys_id);
if (err) if (err)
goto err_free; goto err_free_percpu_ref;
err = online_css(css); err = online_css(css);
if (err) if (err)
goto err_free; goto err_clear_dir;
dget(cgrp->dentry); dget(cgrp->dentry);
css_get(css->parent); css_get(css->parent);
...@@ -4138,8 +4138,11 @@ static int create_css(struct cgroup *cgrp, struct cgroup_subsys *ss) ...@@ -4138,8 +4138,11 @@ static int create_css(struct cgroup *cgrp, struct cgroup_subsys *ss)
return 0; return 0;
err_free: err_clear_dir:
cgroup_clear_dir(css->cgroup, 1 << css->ss->subsys_id);
err_free_percpu_ref:
percpu_ref_cancel_init(&css->refcnt); percpu_ref_cancel_init(&css->refcnt);
err_free_css:
ss->css_free(css); ss->css_free(css);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment