HV: check vm id param when dispatching hypercall

If the vmcall param passed from guest is representing a vmid, we should
make sure it is a valid one because it is a pre-condition of following
get_vm_from_vmid(). And then we don't need to do NULL VM pointer check
in is_valid_vm() because get_vm_from_vmid() would never return NULL.

Tracked-On: #2978

Signed-off-by: Victor Sun <victor.sun@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Victor Sun
2019-04-18 23:03:17 +08:00
committed by wenlingz
parent 1b7d33a426
commit 3bb4308361
3 changed files with 80 additions and 38 deletions

View File

@@ -428,11 +428,11 @@ struct acrn_vuart *vuart_console_active(void)
if (console_vmid < CONFIG_MAX_VM_NUM) {
vm = get_vm_from_vmid(console_vmid);
if (is_valid_vm(vm)) {
vu = vm_console_vuart(vm);
}
}
if (is_valid_vm(vm)) {
vu = vm_console_vuart(vm);
}
return (vu && vu->active) ? vu : NULL;
}