[CRIU] [PATCH] criu: seize -- Don't left dangling @processes_to_wait_pids pointer
Cyrill Gorcunov
gorcunov at gmail.com
Thu Mar 17 07:09:22 PDT 2016
If an error occured during freezer_wait_processes we are
freeing processes_to_wait_pids array but same time
take freezer_detach on error path to execute, which
lead in nil dereference in best case.
Simply zap dangling pointer and make sure it exist
in freezer_detach.
Signed-off-by: Cyrill Gorcunov <gorcunov at virtuozzo.com>
---
criu/seize.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/criu/seize.c b/criu/seize.c
index 0606586..6dfd086 100644
--- a/criu/seize.c
+++ b/criu/seize.c
@@ -203,6 +203,7 @@ static int freezer_wait_processes()
if (pid < 0) {
pr_perror("Unable to wait processes");
xfree(processes_to_wait_pids);
+ processes_to_wait_pids = NULL;
return -1;
}
pr_warn("Unexpected process %d in the freezer cgroup (status 0x%x)\n", pid, status);
@@ -220,7 +221,7 @@ static int freezer_detach(void)
if (!opts.freeze_cgroup)
return 0;
- for (i = 0; i < processes_to_wait; i++) {
+ for (i = 0; i < processes_to_wait && processes_to_wait_pids; i++) {
pid_t pid = processes_to_wait_pids[i];
int status, save_errno;
--
2.5.0
More information about the CRIU
mailing list