diff options
author | Tiwei Bie <tiwei.bie@intel.com> | 2018-07-20 16:36:44 +0800 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2018-08-03 11:35:21 +0300 |
commit | 388a86df9c59334e94ede099526509d8f466b0c8 (patch) | |
tree | 6e38dc74775cdcdfca6dcdc4dd09b59cf0f1440e /hw | |
parent | f7502360397d291be04bc040e9f96c92ff2d8030 (diff) | |
download | qemu-388a86df9c59334e94ede099526509d8f466b0c8.zip |
vhost: check region type before casting
Check region type first before casting the memory region
to IOMMUMemoryRegion. Otherwise QEMU will abort with below
error message when casting non-IOMMU memory region:
vhost_iommu_region_add: Object 0x561f28bce4f0 is not an
instance of type qemu:iommu-memory-region
Fixes: cb1efcf462a2 ("iommu: Add IOMMU index argument to notifier APIs")
Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/virtio/vhost.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index b129cb9ddd..d4cb5894a8 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -663,12 +663,14 @@ static void vhost_iommu_region_add(MemoryListener *listener, struct vhost_iommu *iommu; Int128 end; int iommu_idx; - IOMMUMemoryRegion *iommu_mr = IOMMU_MEMORY_REGION(section->mr); + IOMMUMemoryRegion *iommu_mr; if (!memory_region_is_iommu(section->mr)) { return; } + iommu_mr = IOMMU_MEMORY_REGION(section->mr); + iommu = g_malloc0(sizeof(*iommu)); end = int128_add(int128_make64(section->offset_within_region), section->size); |