hv: bugfix for hv-emulated device de-init

- fix bug in 'hcall_destroy_vdev()', the availability of
   vpci device shall be checked on 'target_vm".

 - refine 'vpci_update_one_vbar()' to avoid potential NULL
   pointer access.

Tracked-On: #5490
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
This commit is contained in:
Yonghua Huang
2020-11-08 10:46:59 +08:00
committed by wenlingz
parent 68dc8d9f8f
commit 49a773ab54
3 changed files with 12 additions and 4 deletions

View File

@@ -1241,7 +1241,7 @@ int32_t hcall_destroy_vdev(struct acrn_vm *vm, struct acrn_vm *target_vm, __unus
op = find_emul_dev_ops(&dev);
if (op != NULL) {
bdf.value = (uint16_t) dev.slot;
vdev = pci_find_vdev(&vm->vpci, bdf);
vdev = pci_find_vdev(&target_vm->vpci, bdf);
if (vdev != NULL) {
vdev->pci_dev_config->vbdf.value = UNASSIGNED_VBDF;
if (op->destroy != NULL) {