[CRIU] [PATCH 2/2] cgroup: umount cg_yard after opening it

Andrew Vagin avagin at openvz.org
Wed Jul 16 06:46:45 PDT 2014


Signed-off-by: Andrew Vagin <avagin at openvz.org>
---
 cgroup.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/cgroup.c b/cgroup.c
index 71ac271..5128911 100644
--- a/cgroup.c
+++ b/cgroup.c
@@ -38,7 +38,6 @@ static unsigned int n_sets;
 static CgSetEntry **rst_sets;
 static unsigned int n_controllers;
 static CgControllerEntry **controllers;
-static char *cg_yard;
 static struct cg_set *root_cgset; /* Set root item lives in */
 static struct cg_set *criu_cgset; /* Set criu process lives in */
 static u32 cg_set_ids = 1;
@@ -654,13 +653,7 @@ int prepare_task_cgroup(struct pstree_item *me)
 
 void fini_cgroup(void)
 {
-	if (!cg_yard)
-		return;
-
 	close_service_fd(CGROUP_YARD);
-	umount2(cg_yard, MNT_DETACH);
-	rmdir(cg_yard);
-	xfree(cg_yard);
 }
 
 static int prepare_cgroup_dirs(char *paux, size_t off, CgroupDirEntry **ents, size_t n_ents)
@@ -706,6 +699,7 @@ static int prepare_cgroup_sfd(CgroupEntry *ce)
 {
 	int off, i;
 	char paux[PATH_MAX];
+	char *cg_yard;
 
 	pr_info("Preparing cgroups yard\n");
 
@@ -792,6 +786,12 @@ static int prepare_cgroup_sfd(CgroupEntry *ce)
 	return 0;
 
 err:
+	if (cg_yard) {
+		umount2(cg_yard, MNT_DETACH);
+		rmdir(cg_yard);
+		xfree(cg_yard);
+	}
+
 	fini_cgroup();
 	return -1;
 }
-- 
1.9.3



More information about the CRIU mailing list