From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39217) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJ5KN-0000FL-L3 for qemu-devel@nongnu.org; Wed, 04 Feb 2015 14:09:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YJ5KM-00035s-Q9 for qemu-devel@nongnu.org; Wed, 04 Feb 2015 14:09:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56769) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJ5KM-00035n-Ih for qemu-devel@nongnu.org; Wed, 04 Feb 2015 14:09:30 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t14J9UU3023506 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 4 Feb 2015 14:09:30 -0500 From: Alex Williamson Date: Wed, 04 Feb 2015 12:09:29 -0700 Message-ID: <20150204190929.24612.21170.stgit@bling.home> In-Reply-To: <20150204190814.24612.42368.stgit@bling.home> References: <20150204190814.24612.42368.stgit@bling.home> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PULL 2/2] vfio-pci: Fix missing unparent of dynamically allocated MemoryRegion List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com 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 --- hw/vfio/pci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 014a92c..29caabc 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; }