From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:56831) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIeGe-0006CK-2G for qemu-devel@nongnu.org; Thu, 21 Mar 2013 08:06:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UIeGa-0006cx-LK for qemu-devel@nongnu.org; Thu, 21 Mar 2013 08:06:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:5428) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIeGa-0006co-EA for qemu-devel@nongnu.org; Thu, 21 Mar 2013 08:06:44 -0400 Date: Thu, 21 Mar 2013 14:07:13 +0200 From: "Michael S. Tsirkin" Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: [Qemu-devel] [PATCH v9 2/3] qom: call class destructor before unparent List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori , Markus Armbruster Cc: Kevin Wolf , Eduardo Habkost , libvir-list@redhat.com, Stefan Hajnoczi , qemu-devel@nongnu.org, Luiz Capitulino , Gerd Hoffmann , Paolo Bonzini , afaerber@suse.de Make sure object is valid when destructor is called. Signed-off-by: Michael S. Tsirkin --- qom/object.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qom/object.c b/qom/object.c index 3d638ff..a0e3cbe 100644 --- a/qom/object.c +++ b/qom/object.c @@ -363,12 +363,12 @@ static void object_property_del_child(Object *obj, Object *child, Error **errp) void object_unparent(Object *obj) { object_ref(obj); - if (obj->parent) { - object_property_del_child(obj->parent, obj, NULL); - } if (obj->class->unparent) { (obj->class->unparent)(obj); } + if (obj->parent) { + object_property_del_child(obj->parent, obj, NULL); + } object_unref(obj); } -- MST