From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NiauN-0002os-8n for qemu-devel@nongnu.org; Fri, 19 Feb 2010 17:01:11 -0500 Received: from [199.232.76.173] (port=48978 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NiauM-0002oa-S1 for qemu-devel@nongnu.org; Fri, 19 Feb 2010 17:01:10 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NiauL-00024m-7X for qemu-devel@nongnu.org; Fri, 19 Feb 2010 17:01:10 -0500 Received: from mail-yw0-f197.google.com ([209.85.211.197]:44950) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NiauK-00024g-Td for qemu-devel@nongnu.org; Fri, 19 Feb 2010 17:01:09 -0500 Received: by ywh35 with SMTP id 35so523095ywh.4 for ; Fri, 19 Feb 2010 14:01:08 -0800 (PST) Message-ID: <4B7F0A21.3000104@codemonkey.ws> Date: Fri, 19 Feb 2010 16:01:05 -0600 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] qdev: Free opts on failed do_device_add References: <1266322358-7075-1-git-send-email-kwolf@redhat.com> In-Reply-To: <1266322358-7075-1-git-send-email-kwolf@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: qemu-devel@nongnu.org On 02/16/2010 06:12 AM, Kevin Wolf wrote: > 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 > Applied. Thanks. Regards, Anthony Liguori > --- > 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) >