hv: fix the vm pointer check before use

After using get_vm_from_vmid(), vm pointer is always not NULL. But there are still many NULL pointer checks.
This commit replaced the NULL vm pointer check with a validation check which checks the vm status.
In addition, NULL check for pointer returned by get_sos_vm() and get_vm_config() is removed.

Tracked-On: #2520
Signed-off-by: Yan, Like <like.yan@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Yan, Like
2019-03-29 14:27:13 +08:00
committed by ACRN System Integration
parent 275625af16
commit ede1459e19
9 changed files with 43 additions and 40 deletions

View File

@@ -554,11 +554,9 @@ void vpci_reset_ptdev_intr_info(const struct acrn_vm *target_vm, uint16_t vbdf,
if (vdev->vpci->vm == target_vm) {
vm = get_sos_vm();
if (vm != NULL) {
vdev->vpci = &vm->vpci;
/* vbdf equals to pbdf in sos */
vdev->vbdf.value = vdev->pdev->bdf.value;
}
vdev->vpci = &vm->vpci;
/* vbdf equals to pbdf in sos */
vdev->vbdf.value = vdev->pdev->bdf.value;
}
}
}