diff options
author | Li Zefan <lizefan@huawei.com> | 2014-03-18 05:02:36 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2014-03-18 17:15:36 -0400 |
commit | 3eb59ec64fc7a3f4576da23f811b39331b830ba2 (patch) | |
tree | 600d9c6c0b0d75017cc373a6262bc27d4836ce8d | |
parent | 99afb0fd5f05aac467ffa85c36778fec4396209b (diff) |
cgroup: fix a failure path in create_css()
If online_css() fails, we should remove cgroup files belonging
to css->ss.
Signed-off-by: Li Zefan <lizefan@huawei.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
-rw-r--r-- | kernel/cgroup.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 105f273b6f86..0c753ddd223b 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -4112,17 +4112,17 @@ static int create_css(struct cgroup *cgrp, struct cgroup_subsys *ss) | |||
4112 | 4112 | ||
4113 | err = percpu_ref_init(&css->refcnt, css_release); | 4113 | err = percpu_ref_init(&css->refcnt, css_release); |
4114 | if (err) | 4114 | if (err) |
4115 | goto err_free; | 4115 | goto err_free_css; |
4116 | 4116 | ||
4117 | init_css(css, ss, cgrp); | 4117 | init_css(css, ss, cgrp); |
4118 | 4118 | ||
4119 | err = cgroup_populate_dir(cgrp, 1 << ss->subsys_id); | 4119 | err = cgroup_populate_dir(cgrp, 1 << ss->subsys_id); |
4120 | if (err) | 4120 | if (err) |
4121 | goto err_free; | 4121 | goto err_free_percpu_ref; |
4122 | 4122 | ||
4123 | err = online_css(css); | 4123 | err = online_css(css); |
4124 | if (err) | 4124 | if (err) |
4125 | goto err_free; | 4125 | goto err_clear_dir; |
4126 | 4126 | ||
4127 | dget(cgrp->dentry); | 4127 | dget(cgrp->dentry); |
4128 | css_get(css->parent); | 4128 | css_get(css->parent); |
@@ -4138,8 +4138,11 @@ static int create_css(struct cgroup *cgrp, struct cgroup_subsys *ss) | |||
4138 | 4138 | ||
4139 | return 0; | 4139 | return 0; |
4140 | 4140 | ||
4141 | err_free: | 4141 | err_clear_dir: |
4142 | cgroup_clear_dir(css->cgroup, 1 << css->ss->subsys_id); | ||
4143 | err_free_percpu_ref: | ||
4142 | percpu_ref_cancel_init(&css->refcnt); | 4144 | percpu_ref_cancel_init(&css->refcnt); |
4145 | err_free_css: | ||
4143 | ss->css_free(css); | 4146 | ss->css_free(css); |
4144 | return err; | 4147 | return err; |
4145 | } | 4148 | } |