hv: check the validity of 'pdev' in 'set_ptdev_intr_info'

This patch checks the validity of 'vdev->pdev' to
 ensure physical device is linked to 'vdev'.
 this check is to avoid some potential hypervisor
 crash when destroying VM with crafted input.

Tracked-On: #4336
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Reviewed-by: Fei Li <fei1.li@intel.com>
This commit is contained in:
Yonghua Huang 2020-01-07 11:44:17 +08:00 committed by wenlingz
parent fe03d8700d
commit 82b89fd04c

View File

@ -581,7 +581,7 @@ void vpci_set_ptdev_intr_info(struct acrn_vm *target_vm, uint16_t vbdf, uint16_t
sos_vm = get_sos_vm();
spinlock_obtain(&sos_vm->vpci.lock);
vdev = pci_find_vdev(&sos_vm->vpci, bdf);
if (vdev == NULL) {
if ((vdev == NULL) || (vdev->pdev == NULL)) {
pr_err("%s, can't find PCI device for vm%d, vbdf (0x%x) pbdf (0x%x)", __func__,
target_vm->vm_id, vbdf, pbdf);
} else {