From patchwork Wed Feb 4 19:09:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 436460 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id C44601401DE for ; Thu, 5 Feb 2015 06:10:10 +1100 (AEDT) Received: from localhost ([::1]:38215 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YJ5Ky-0001Cn-KN for incoming@patchwork.ozlabs.org; Wed, 04 Feb 2015 14:10:08 -0500 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 Received: from bling.home (ovpn-113-103.phx2.redhat.com [10.3.113.103]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t14J9T87005429; Wed, 4 Feb 2015 14:09:29 -0500 From: Alex Williamson To: qemu-devel@nongnu.org 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> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: alex.williamson@redhat.com Subject: [Qemu-devel] [PULL 2/2] vfio-pci: Fix missing unparent of dynamically allocated MemoryRegion X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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; }