From: Kevin Wolf Date: Tue, 16 Feb 2010 12:12:38 +0000 (+0100) Subject: qdev: Free opts on failed do_device_add X-Git-Tag: TizenStudio_2.0_p2.3.2~208^2~8675 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0f853a386739b22e541e6e65ed60a0cb37713340;p=sdk%2Femulator%2Fqemu.git qdev: Free opts on failed do_device_add 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 Signed-off-by: Anthony Liguori --- 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)