From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NhMJ2-0003hD-Kk for qemu-devel@nongnu.org; Tue, 16 Feb 2010 07:13:32 -0500 Received: from [199.232.76.173] (port=41128 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NhMJ2-0003gx-9B for qemu-devel@nongnu.org; Tue, 16 Feb 2010 07:13:32 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NhMIy-0001mx-15 for qemu-devel@nongnu.org; Tue, 16 Feb 2010 07:13:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:7266) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NhMIx-0001mj-J6 for qemu-devel@nongnu.org; Tue, 16 Feb 2010 07:13:27 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o1GCDQ5v022531 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 16 Feb 2010 07:13:26 -0500 Received: from localhost.localdomain (dhcp-5-175.str.redhat.com [10.32.5.175]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o1GCDOQA023822 for ; Tue, 16 Feb 2010 07:13:25 -0500 From: Kevin Wolf Date: Tue, 16 Feb 2010 13:12:38 +0100 Message-Id: <1266322358-7075-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH] qdev: Free opts on failed do_device_add List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org If the device can't be created, don't leak the QemuOpts and release the id of the device that should have been added by the failed device_add. Signed-off-by: Kevin Wolf --- hw/qdev.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/qdev.c b/hw/qdev.c index 539b5a2..d0052d4 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -749,8 +749,11 @@ void do_device_add(Monitor *mon, const QDict *qdict) opts = qemu_opts_parse(&qemu_device_opts, qdict_get_str(qdict, "config"), "driver"); - if (opts && !qdev_device_help(opts)) - qdev_device_add(opts); + if (opts) { + if (qdev_device_help(opts) || qdev_device_add(opts) == NULL) { + qemu_opts_del(opts); + } + } } void do_device_del(Monitor *mon, const QDict *qdict) -- 1.6.6