qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] qdev: Free opts on failed do_device_add
@ 2010-02-16 12:12 Kevin Wolf
  2010-02-16 15:08 ` Gerd Hoffmann
  2010-02-19 22:01 ` Anthony Liguori
  0 siblings, 2 replies; 3+ messages in thread
From: Kevin Wolf @ 2010-02-16 12:12 UTC (permalink / raw)
  To: qemu-devel

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 <kwolf@redhat.com>
---
 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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] qdev: Free opts on failed do_device_add
  2010-02-16 12:12 [Qemu-devel] [PATCH] qdev: Free opts on failed do_device_add Kevin Wolf
@ 2010-02-16 15:08 ` Gerd Hoffmann
  2010-02-19 22:01 ` Anthony Liguori
  1 sibling, 0 replies; 3+ messages in thread
From: Gerd Hoffmann @ 2010-02-16 15:08 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: qemu-devel

On 02/16/10 13:12, 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.

Acked-by: Gerd Hoffmann <kraxel@redhat.com>

cheers,
   Gerd

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] qdev: Free opts on failed do_device_add
  2010-02-16 12:12 [Qemu-devel] [PATCH] qdev: Free opts on failed do_device_add Kevin Wolf
  2010-02-16 15:08 ` Gerd Hoffmann
@ 2010-02-19 22:01 ` Anthony Liguori
  1 sibling, 0 replies; 3+ messages in thread
From: Anthony Liguori @ 2010-02-19 22:01 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: qemu-devel

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<kwolf@redhat.com>
>    

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)
>    

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-02-19 22:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-16 12:12 [Qemu-devel] [PATCH] qdev: Free opts on failed do_device_add Kevin Wolf
2010-02-16 15:08 ` Gerd Hoffmann
2010-02-19 22:01 ` Anthony Liguori

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).