aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Auger <eric.auger@redhat.com>2024-07-01 10:48:53 +0200
committerCédric Le Goater <clg@redhat.com>2024-07-09 11:50:37 +0200
commit37baedf8e8a78cf799956447e40da79b967882bb (patch)
treec9c06afd28dab95dda04a2d41a7733a7d82c0d87
parent44b7329de469c121555a1acf9b288f3ae71b8e61 (diff)
downloadqemu-37baedf8e8a78cf799956447e40da79b967882bb.zip
qemu-37baedf8e8a78cf799956447e40da79b967882bb.tar.gz
qemu-37baedf8e8a78cf799956447e40da79b967882bb.tar.bz2
virtio-iommu: Fix error handling in virtio_iommu_set_host_iova_ranges()
In case no IOMMUPciBus/IOMMUDevice are found we need to properly set the error handle and return. Fixes : Coverity CID 1549006 Signed-off-by: Eric Auger <eric.auger@redhat.com> Fixes: cf2647a76e ("virtio-iommu: Compute host reserved regions") Reviewed-by: Cédric Le Goater <clg@redhat.com> Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
-rw-r--r--hw/virtio/virtio-iommu.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c
index 7c54c6b..8fe69ab 100644
--- a/hw/virtio/virtio-iommu.c
+++ b/hw/virtio/virtio-iommu.c
@@ -563,10 +563,15 @@ static int virtio_iommu_set_host_iova_ranges(VirtIOIOMMU *s, PCIBus *bus,
int ret = -EINVAL;
if (!sbus) {
- error_report("%s no sbus", __func__);
+ error_setg(errp, "%s: no IOMMUPciBus found!", __func__);
+ return ret;
}
sdev = sbus->pbdev[devfn];
+ if (!sdev) {
+ error_setg(errp, "%s: no IOMMUDevice found!", __func__);
+ return ret;
+ }
current_ranges = sdev->host_resv_ranges;