From patchwork Mon Oct 19 11:11:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 532227 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 A4A34140134 for ; Mon, 19 Oct 2015 22:12:05 +1100 (AEDT) Received: from localhost ([::1]:38292 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zo8MF-0000vK-Sl for incoming@patchwork.ozlabs.org; Mon, 19 Oct 2015 07:12:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42711) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zo8Lx-0000e2-Q5 for qemu-devel@nongnu.org; Mon, 19 Oct 2015 07:11:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zo8Lu-0007Uo-Jp for qemu-devel@nongnu.org; Mon, 19 Oct 2015 07:11:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36774) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zo8Lu-0007UP-ED for qemu-devel@nongnu.org; Mon, 19 Oct 2015 07:11:42 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id C122AC0C1898; Mon, 19 Oct 2015 11:11:41 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-112-64.ams2.redhat.com [10.36.112.64]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t9JBBePk015717; Mon, 19 Oct 2015 07:11:40 -0400 From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 19 Oct 2015 13:11:39 +0200 Message-Id: <1445253099-16894-1-git-send-email-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: afaerber@suse.de Subject: [Qemu-devel] [PATCH] qdev: free qemu-opts when the QOM path goes away 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 Otherwise there is a race where the DEVICE_DELETED event has been sent but attempts to reuse the ID will fail. Reported-by: Michael S. Tsirkin Signed-off-by: Paolo Bonzini Reviewed-by: Markus Armbruster --- hw/core/qdev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 4ab04aa..92bd8bb 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -1203,7 +1203,6 @@ static void device_finalize(Object *obj) NamedGPIOList *ngl, *next; DeviceState *dev = DEVICE(obj); - qemu_opts_del(dev->opts); QLIST_FOREACH_SAFE(ngl, &dev->gpios, node, next) { QLIST_REMOVE(ngl, node); @@ -1251,6 +1250,9 @@ static void device_unparent(Object *obj) qapi_event_send_device_deleted(!!dev->id, dev->id, path, &error_abort); g_free(path); } + + qemu_opts_del(dev->opts); + dev->opts = NULL; } static void device_class_init(ObjectClass *class, void *data)