If online_css() fails, we should remove cgroup files belonging to css->ss.
Unified · Split
| @@ -4112,17 +4112,17 @@ static int create_css(struct cgroup *cgrp, struct cgroup_subsys *ss) · 4111 unmodified lines | ||
| 4112 | 4112 | |
| 4113 | 4113 | err = percpu_ref_init(&css->refcnt, css_release); |
| 4114 | 4114 | if (err) |
| 4115 | − goto err_free; | |
| 4115 | + goto err_free_css; | |
| 4116 | 4116 | |
| 4117 | 4117 | init_css(css, ss, cgrp); |
| 4118 | 4118 | |
| 4119 | 4119 | err = cgroup_populate_dir(cgrp, 1 << ss->subsys_id); |
| 4120 | 4120 | if (err) |
| 4121 | − goto err_free; | |
| 4121 | + goto err_free_percpu_ref; | |
| 4122 | 4122 | |
| 4123 | 4123 | err = online_css(css); |
| 4124 | 4124 | if (err) |
| 4125 | − goto err_free; | |
| 4125 | + goto err_clear_dir; | |
| 4126 | 4126 | |
| 4127 | 4127 | dget(cgrp->dentry); |
| 4128 | 4128 | css_get(css->parent); |
| @@ -4138,8 +4138,11 @@ static int create_css(struct cgroup *cgrp, struct cgroup_subsys *ss) · 9 unmodified lines | ||
| 4138 | 4138 | |
| 4139 | 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 | 4144 | percpu_ref_cancel_init(&css->refcnt); |
| 4145 | +err_free_css: | |
| 4143 | 4146 | ss->css_free(css); |
| 4144 | 4147 | return err; |
| 4145 | 4148 | } |