qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] vhost: check region type before casting
@ 2018-07-20  8:36 Tiwei Bie
  2018-07-20  8:52 ` no-reply
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Tiwei Bie @ 2018-07-20  8:36 UTC (permalink / raw)
  To: mst, jasowang; +Cc: qemu-devel, Peter Maydell

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>
---
 hw/virtio/vhost.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

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);
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-08-02  9:14 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-20  8:36 [Qemu-devel] [PATCH] vhost: check region type before casting Tiwei Bie
2018-07-20  8:52 ` no-reply
2018-07-20  9:08 ` Peter Maydell
2018-08-01  8:22 ` Tiwei Bie
2018-08-01  8:33   ` Jason Wang
2018-08-01 10:13   ` Peter Maydell
2018-08-01 11:02     ` Tiwei Bie
2018-08-01 21:58     ` Michael S. Tsirkin
2018-08-02  8:51       ` Peter Maydell
2018-08-02  9:13         ` Michael S. Tsirkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).