Skip to content

Commit e8c8656

Browse files
lyan3wenlingz
authored andcommitted
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 <like.yan@intel.com>
1 parent da3b027 commit e8c8656

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

tools/acrn-manager/acrnctl.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,8 +504,13 @@ static int wait_vm_stop(const char * vmname, unsigned int timeout)
504504
vmmngr_update();
505505

506506
s = vmmngr_find(vmname);
507-
if (s->state == VM_CREATED)
508-
return 0;
507+
if (s == NULL) {
508+
printf("%s: vm %s not found\n", __func__, vmname);
509+
return -1;
510+
} else {
511+
if (s->state == VM_CREATED)
512+
return 0;
513+
}
509514

510515
sleep(1);
511516
} while (t--);

0 commit comments

Comments
 (0)