Commit be5062c1 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

cg: Add rollback for add_cgroup

If add_cgroup_properties failed we have @ncd sitting
in @match->children or @current_controller->heads
list, and then we free @ncd entry leaving those
lists carrying dead pointers.

Add proper rollback action.
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@virtuozzo.com>
Acked-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 94bfda90
...@@ -549,8 +549,14 @@ static int add_cgroup(const char *fpath, const struct stat *sb, int typeflag) ...@@ -549,8 +549,14 @@ static int add_cgroup(const char *fpath, const struct stat *sb, int typeflag)
INIT_LIST_HEAD(&ncd->properties); INIT_LIST_HEAD(&ncd->properties);
ncd->n_properties = 0; ncd->n_properties = 0;
if (add_cgroup_properties(fpath, ncd, current_controller) < 0) if (add_cgroup_properties(fpath, ncd, current_controller) < 0) {
list_del(&ncd->siblings);
if (mtype == PARENT_MATCH)
match->n_children--;
else if (mtype == NO_MATCH)
current_controller->n_heads--;
goto out; goto out;
}
} }
return 0; return 0;
......
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