@@ -630,9 +630,13 @@ static void vfio_listener_region_add(MemoryListener *listener,
section->offset_within_region,
int128_get64(llend),
iommu_idx);
- QLIST_INSERT_HEAD(&container->giommu_list, giommu, giommu_next);
- memory_region_register_iommu_notifier(section->mr, &giommu->n);
+ ret = memory_region_register_iommu_notifier(section->mr, &giommu->n);
+ if (ret) {
+ g_free(giommu);
+ goto fail;
+ }
+ QLIST_INSERT_HEAD(&container->giommu_list, giommu, giommu_next);
memory_region_iommu_replay(giommu->iommu, &giommu->n);
return;
Now memory_region_register_iommu_notifier() is allowed to fail, let's handle the returned value in vfio_listener_region_add(). This will allow to remove the error handling (exit) in the IOMMUs that implement a notify_flag_changed() that sometimes cannot accept the MAP flag. Signed-off-by: Eric Auger <eric.auger@redhat.com> --- hw/vfio/common.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)