Skip to content

Commit

Permalink
restore: cleanup cgroup properly in error path
Browse files Browse the repository at this point in the history
Cgroup yard is setup in crtools_prepare_shared. But it is not cleaned up
properly in some code path, which leads cgroup mountpoint leaking.

Signed-off-by: Liu Hua <[email protected]>
  • Loading branch information
Liu Hua committed Jul 5, 2021
1 parent 15266a4 commit bd1619a
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions criu/cr-restore.c
Original file line number Diff line number Diff line change
Expand Up @@ -2459,8 +2459,6 @@ static int restore_root_task(struct pstree_item *init)
if (restore_freezer_state())
pr_err("Unable to restore freezer state\n");

fini_cgroup();

/* Detaches from processes and they continue run through sigreturn. */
if (finalize_restore_detach())
goto out_kill_network_unlocked;
Expand Down Expand Up @@ -2507,7 +2505,6 @@ static int restore_root_task(struct pstree_item *init)
}

out:
fini_cgroup();
depopulate_roots_yard(mnt_ns_fd, true);
stop_usernsd();
__restore_switch_stage(CR_STATE_FAIL);
Expand Down Expand Up @@ -2598,12 +2595,14 @@ int cr_restore_tasks(void)
goto err;

if (criu_signals_setup() < 0)
goto err;
goto clean_cgroup;

if (prepare_lazy_pages_socket() < 0)
goto err;
goto clean_cgroup;

ret = restore_root_task(root_item);
clean_cgroup:
fini_cgroup();
err:
cr_plugin_fini(CR_PLUGIN_STAGE__RESTORE, ret);
return ret;
Expand Down

0 comments on commit bd1619a

Please sign in to comment.