[CRIU] [PATCH] criu: parasite_prepare_threads: free memory on error path
Mike Rapoport
rppt at linux.vnet.ibm.com
Thu Aug 23 18:18:09 MSK 2018
Fixes cov 191305
Signed-off-by: Mike Rapoport <rppt at linux.vnet.ibm.com>
---
criu/parasite-syscall.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/criu/parasite-syscall.c b/criu/parasite-syscall.c
index 10504ed..b9788a4 100644
--- a/criu/parasite-syscall.c
+++ b/criu/parasite-syscall.c
@@ -477,7 +477,7 @@ static int parasite_prepare_threads(struct parasite_ctl *ctl,
thread_sp = xzalloc(sizeof(*thread_sp) * item->nr_threads);
if (!thread_sp)
- return -1;
+ goto free_ctls;
for (i = 0; i < item->nr_threads; i++) {
struct pid *tid = &item->threads[i];
@@ -489,7 +489,7 @@ static int parasite_prepare_threads(struct parasite_ctl *ctl,
thread_ctls[i] = compel_prepare_thread(ctl, tid->real);
if (!thread_ctls[i])
- return -1;
+ goto free_sp;
thread_sp[i] = compel_get_thread_sp(thread_ctls[i]);
}
@@ -498,6 +498,12 @@ static int parasite_prepare_threads(struct parasite_ctl *ctl,
dmpi(item)->thread_sp = thread_sp;
return 0;
+
+free_sp:
+ xfree(thread_sp);
+free_ctls:
+ xfree(thread_ctls);
+ return -1;
}
struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item,
--
2.7.4
More information about the CRIU
mailing list