From: Alex Williamson Date: Wed, 4 Feb 2015 18:45:32 +0000 (-0700) Subject: vfio-pci: Fix missing unparent of dynamically allocated MemoryRegion X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=3a4dbe6aa934370a92372528c1255ee1504965ee;p=qemu.git vfio-pci: Fix missing unparent of dynamically allocated MemoryRegion Commit d8d95814609e added explicit object_unparent() calls for dynamically allocated MemoryRegions. The VFIOMSIXInfo structure also contains such a MemoryRegion, covering the mmap'd region of a PCI BAR above the MSI-X table. This structure is freed as part of the class exit function and therefore also needs an explicit object_unparent(). Failing to do this results in random segfaults due to fields within the structure, often the class pointer, being reclaimed and corrupted by the time object_finalize_child_property() is called for the object. Signed-off-by: Alex Williamson Reviewed-by: Paolo Bonzini Cc: qemu-stable@nongnu.org # 2.2 --- diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 014a92ce5f..29caabc149 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -3065,6 +3065,7 @@ static void vfio_put_device(VFIOPCIDevice *vdev) { g_free(vdev->vbasedev.name); if (vdev->msix) { + object_unparent(OBJECT(&vdev->msix->mmap_mem)); g_free(vdev->msix); vdev->msix = NULL; }