[CRIU] [PATCH] service: fix bug, when root_item isn't initialized

Ruslan Kuprieiev kupruser at gmail.com
Wed Dec 18 03:28:35 PST 2013


If restore fails on early stage(like no images in directory), then root_item
might be uninitialized, so when we are trying to send response with root_item->pid
criu crashes.

Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>
---
 cr-service.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/cr-service.c b/cr-service.c
index 2fa89a5..bf780dd 100644
--- a/cr-service.c
+++ b/cr-service.c
@@ -212,7 +212,8 @@ static int restore_using_req(int sk, CriuOpts *req)
 
 	success = true;
 exit:
-	if (send_criu_restore_resp(sk, success, root_item->pid.real) == -1) {
+	if (send_criu_restore_resp(sk, success,
+				   root_item ? root_item->pid.real : -1) == -1) {
 		pr_perror("Can't send response");
 		success = false;
 	}
-- 
1.8.3.2



More information about the CRIU mailing list