[CRIU] [PATCH v2 06/21] restore: Make error path in restore_root_task() accurate

Kirill Tkhai ktkhai at virtuozzo.com
Wed May 31 10:52:39 PDT 2017


Don't call destroy_pid_ns_helpers() twice; add a new case
for that.

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 criu/cr-restore.c |   22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index f0d0fc5e0..6be3877c7 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -2099,7 +2099,7 @@ static int restore_root_task(struct pstree_item *init)
 
 		if (ptrace(PTRACE_SEIZE, init->pid->real, 0, 0)) {
 			pr_perror("Can't attach to init");
-			goto out_kill;
+			goto out_destroy;
 		}
 	}
 
@@ -2111,25 +2111,25 @@ static int restore_root_task(struct pstree_item *init)
 	 * prepare_userns_creds() must be called after filling mappings.
 	 */
 	if ((root_ns_mask & CLONE_NEWUSER) && prepare_userns(init->pid->real, userns_entry))
-		goto out_kill;
+		goto out_destroy;
 
 	pr_info("Wait until namespaces are created\n");
 	ret = restore_wait_inprogress_tasks();
 	if (ret)
-		goto out_kill;
+		goto out_destroy;
 
 	ret = run_scripts(ACT_SETUP_NS);
 	if (ret)
-		goto out_kill;
+		goto out_destroy;
 
 	ret = restore_switch_stage(CR_STATE_PREPARE_NAMESPACES);
 	if (ret)
-		goto out_kill;
+		goto out_destroy;
 
 	if (root_ns_mask & CLONE_NEWNS) {
 		mnt_ns_fd = open_proc(init->pid->real, "ns/mnt");
 		if (mnt_ns_fd < 0)
-			goto out_kill;
+			goto out_destroy;
 	}
 
 	if (opts.empty_ns & CLONE_NEWNET) {
@@ -2142,12 +2142,12 @@ static int restore_root_task(struct pstree_item *init)
 		 */
 		ret = network_lock_internal();
 		if (ret)
-			goto out_kill;
+			goto out_destroy;
 	}
 
 	ret = run_scripts(ACT_POST_SETUP_NS);
 	if (ret)
-		goto out_kill;
+		goto out_destroy;
 
 	__restore_switch_stage(CR_STATE_FORKING);
 
@@ -2155,7 +2155,7 @@ static int restore_root_task(struct pstree_item *init)
 
 	ret = restore_wait_inprogress_tasks();
 	if (ret < 0)
-		goto out_kill;
+		goto out_destroy;
 
 	/*
 	 * Zombies die after CR_STATE_RESTORE which is switched
@@ -2272,9 +2272,9 @@ static int restore_root_task(struct pstree_item *init)
 		wait(NULL);
 
 	return 0;
-
-out_kill:
+out_destroy:
 	destroy_pid_ns_helpers();
+out_kill:
 	/*
 	 * The processes can be killed only when all of them have been created,
 	 * otherwise an external proccesses can be killed.



More information about the CRIU mailing list