From e8c86566b173123cec805b004bd3341c88ec88bc Mon Sep 17 00:00:00 2001 From: "Yan, Like" Date: Tue, 16 Oct 2018 11:15:47 +0800 Subject: [PATCH] tools: acrn-manager: fix a potential NULL pointer dereference check the return value of vmmngr_find() before dereference in wait_vm_stop() Tracked-On: #1479 Signed-off-by: Yan, Like --- tools/acrn-manager/acrnctl.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/acrn-manager/acrnctl.c b/tools/acrn-manager/acrnctl.c index eb252fe49..f3022bdd3 100644 --- a/tools/acrn-manager/acrnctl.c +++ b/tools/acrn-manager/acrnctl.c @@ -504,8 +504,13 @@ static int wait_vm_stop(const char * vmname, unsigned int timeout) vmmngr_update(); s = vmmngr_find(vmname); - if (s->state == VM_CREATED) - return 0; + if (s == NULL) { + printf("%s: vm %s not found\n", __func__, vmname); + return -1; + } else { + if (s->state == VM_CREATED) + return 0; + } sleep(1); } while (t--);