[CRIU] [PATCH 2/3] cg: Add rollback for add_cgroup
Cyrill Gorcunov
gorcunov at openvz.org
Thu Mar 31 07:39:44 PDT 2016
From: Cyrill Gorcunov <gorcunov at virtuozzo.com>
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: Cyrill Gorcunov <gorcunov at virtuozzo.com>
---
criu/cgroup.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/criu/cgroup.c b/criu/cgroup.c
index 676cd0e691f2..44caf3c42fcb 100644
--- a/criu/cgroup.c
+++ b/criu/cgroup.c
@@ -549,8 +549,14 @@ static int add_cgroup(const char *fpath, const struct stat *sb, int typeflag)
INIT_LIST_HEAD(&ncd->properties);
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;
+ }
}
return 0;
--
2.5.5
More information about the CRIU
mailing list