diff --git a/xen/drivers/passthrough/vtd/intremap.c b/xen/drivers/passthrough/vtd/intremap.c index b4ab696243..24e22be320 100644 --- a/xen/drivers/passthrough/vtd/intremap.c +++ b/xen/drivers/passthrough/vtd/intremap.c @@ -563,7 +563,8 @@ void msi_msg_read_remap_rte( struct iommu *iommu = NULL; struct ir_ctrl *ir_ctrl; - drhd = acpi_find_matched_drhd_unit(pdev); + if ( (drhd = acpi_find_matched_drhd_unit(pdev)) == NULL ) + return; iommu = drhd->iommu; ir_ctrl = iommu_ir_ctrl(iommu); @@ -581,7 +582,8 @@ void msi_msg_write_remap_rte( struct iommu *iommu = NULL; struct ir_ctrl *ir_ctrl; - drhd = acpi_find_matched_drhd_unit(pdev); + if ( (drhd = acpi_find_matched_drhd_unit(pdev)) == NULL ) + return; iommu = drhd->iommu; ir_ctrl = iommu_ir_ctrl(iommu); diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c index 157acfc24e..4dabe6f4ec 100644 --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -1343,7 +1343,8 @@ static int reassign_device_ownership( if (!pdev) return -ENODEV; - drhd = acpi_find_matched_drhd_unit(pdev); + if ( (drhd = acpi_find_matched_drhd_unit(pdev)) == NULL ) + return -ENODEV; pdev_iommu = drhd->iommu; domain_context_unmap(source, bus, devfn); @@ -1357,7 +1358,7 @@ static int reassign_device_ownership( for_each_pdev ( source, pdev ) { drhd = acpi_find_matched_drhd_unit(pdev); - if ( drhd->iommu == pdev_iommu ) + if ( drhd && drhd->iommu == pdev_iommu ) { found = 1; break;