hv: fix NULL pointer dereference in "hcall_set_vm_memory_regions()"
'target_vm' returned from 'get_vm_from_vmid()' maybe NULL,
passing to 'is_vm0()' without check.
Acked-by: Eddie Dong
@@ -535,6 +535,10 @@ int32_t hcall_set_vm_memory_regions(struct vm *vm, uint64_t param)
}
target_vm = get_vm_from_vmid(set_regions.vmid);
+ if (target_vm == NULL) {
+ return -EINVAL;
+ }
+
if (is_vm0(target_vm)) {
pr_err("%s: Targeting to service vm", __func__);
return -EFAULT;
