summaryrefslogtreecommitdiffstats
path: root/hw/virtio
diff options
context:
space:
mode:
authorEric Auger2020-09-08 21:33:08 +0200
committerMichael S. Tsirkin2020-09-29 08:14:30 +0200
commit59bf980d22af00880ab7f24f3da3c40e0cf13e98 (patch)
tree3e4793d9dfad50b6eec7dddc0332dd256a430190 /hw/virtio
parentcphp: remove deprecated cpu-add command(s) (diff)
downloadqemu-59bf980d22af00880ab7f24f3da3c40e0cf13e98.tar.gz
qemu-59bf980d22af00880ab7f24f3da3c40e0cf13e98.tar.xz
qemu-59bf980d22af00880ab7f24f3da3c40e0cf13e98.zip
virtio-iommu: Check gtrees are non null before destroying them
If realize fails, domains and endpoints trees may be NULL. On unrealize(), this produces assertions: "GLib: g_tree_destroy: assertion 'tree != NULL' failed" Check that the trees are non NULL before destroying them. Cc: qemu-stable@nongnu.org Signed-off-by: Eric Auger <eric.auger@redhat.com> Reviewed-by: Cornelia Huck <cohuck@redhat.com> Message-Id: <20200908193309.20569-2-eric.auger@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/virtio')
-rw-r--r--hw/virtio/virtio-iommu.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c
index 5d56865e56..21ec63b108 100644
--- a/hw/virtio/virtio-iommu.c
+++ b/hw/virtio/virtio-iommu.c
@@ -801,8 +801,12 @@ static void virtio_iommu_device_unrealize(DeviceState *dev)
VirtIOIOMMU *s = VIRTIO_IOMMU(dev);
g_hash_table_destroy(s->as_by_busptr);
- g_tree_destroy(s->domains);
- g_tree_destroy(s->endpoints);
+ if (s->domains) {
+ g_tree_destroy(s->domains);
+ }
+ if (s->endpoints) {
+ g_tree_destroy(s->endpoints);
+ }
virtio_delete_queue(s->req_vq);
virtio_delete_queue(s->event_vq);