Skip to content

Commit

Permalink
cgroup: fix a failure path in create_css()
Browse files Browse the repository at this point in the history
If online_css() fails, we should remove cgroup files belonging
to css->ss.

Signed-off-by: Li Zefan <[email protected]>
Signed-off-by: Tejun Heo <[email protected]>
  • Loading branch information
lizf-os authored and htejun committed Mar 18, 2014
1 parent 99afb0f commit 3eb59ec
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions kernel/cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -4112,17 +4112,17 @@ static int create_css(struct cgroup *cgrp, struct cgroup_subsys *ss)

err = percpu_ref_init(&css->refcnt, css_release);
if (err)
goto err_free;
goto err_free_css;

init_css(css, ss, cgrp);

err = cgroup_populate_dir(cgrp, 1 << ss->subsys_id);
if (err)
goto err_free;
goto err_free_percpu_ref;

err = online_css(css);
if (err)
goto err_free;
goto err_clear_dir;

dget(cgrp->dentry);
css_get(css->parent);
Expand All @@ -4138,8 +4138,11 @@ static int create_css(struct cgroup *cgrp, struct cgroup_subsys *ss)

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);
err_free_css:
ss->css_free(css);
return err;
}
Expand Down

0 comments on commit 3eb59ec

Please sign in to comment.