diff options
| author | Kevin Wolf <kwolf@redhat.com> | 2010-02-16 13:12:38 +0100 |
|---|---|---|
| committer | Anthony Liguori <aliguori@us.ibm.com> | 2010-02-19 15:53:54 -0600 |
| commit | 0f853a386739b22e541e6e65ed60a0cb37713340 (patch) | |
| tree | 18f958f9bd487a54fa8f6dc9d6e89667470464fc /hw/qdev.c | |
| parent | 4c5b10b7b65eb613822b2ebbaf88b15edd2c3765 (diff) | |
| download | focaccia-qemu-0f853a386739b22e541e6e65ed60a0cb37713340.tar.gz focaccia-qemu-0f853a386739b22e541e6e65ed60a0cb37713340.zip | |
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 <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/qdev.c')
| -rw-r--r-- | hw/qdev.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/hw/qdev.c b/hw/qdev.c index 539b5a2009..d0052d436c 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) |