Commit 0602bca4 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

cg: Add rollback in get_cg_set

In case of error inside collect_cgroups we need

- @ctls list has been spliced into @cs->ctls so we cant just free it,
   but rather use put_ctls on @cs->ctls

- delete @cs->l from global @cg_sets list before free it
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@virtuozzo.com>
Reviewed-by: 's avatarAndrew Vagin <avagin@openvz.org>
Acked-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent be5062c1
...@@ -190,7 +190,7 @@ static struct cg_set *get_cg_set(struct list_head *ctls, unsigned int n_ctls, bo ...@@ -190,7 +190,7 @@ static struct cg_set *get_cg_set(struct list_head *ctls, unsigned int n_ctls, bo
if (cs) { if (cs) {
cs->id = cg_set_ids++; cs->id = cg_set_ids++;
INIT_LIST_HEAD(&cs->ctls); INIT_LIST_HEAD(&cs->ctls);
list_splice(ctls, &cs->ctls); list_splice_init(ctls, &cs->ctls);
cs->n_ctls = n_ctls; cs->n_ctls = n_ctls;
list_add_tail(&cs->l, &cg_sets); list_add_tail(&cs->l, &cg_sets);
n_sets++; n_sets++;
...@@ -203,7 +203,9 @@ static struct cg_set *get_cg_set(struct list_head *ctls, unsigned int n_ctls, bo ...@@ -203,7 +203,9 @@ static struct cg_set *get_cg_set(struct list_head *ctls, unsigned int n_ctls, bo
} }
if (collect && collect_cgroups(&cs->ctls)) { if (collect && collect_cgroups(&cs->ctls)) {
put_ctls(ctls); list_del(&cs->l);
n_sets--;
put_ctls(&cs->ctls);
xfree(cs); xfree(cs);
return NULL; return NULL;
} }
......
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