提交 0f853a38 编写于 作者: K Kevin Wolf 提交者: Anthony Liguori

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: NKevin Wolf <kwolf@redhat.com>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 4c5b10b7
...@@ -749,8 +749,11 @@ void do_device_add(Monitor *mon, const QDict *qdict) ...@@ -749,8 +749,11 @@ void do_device_add(Monitor *mon, const QDict *qdict)
opts = qemu_opts_parse(&qemu_device_opts, opts = qemu_opts_parse(&qemu_device_opts,
qdict_get_str(qdict, "config"), "driver"); qdict_get_str(qdict, "config"), "driver");
if (opts && !qdev_device_help(opts)) if (opts) {
qdev_device_add(opts); if (qdev_device_help(opts) || qdev_device_add(opts) == NULL) {
qemu_opts_del(opts);
}
}
} }
void do_device_del(Monitor *mon, const QDict *qdict) void do_device_del(Monitor *mon, const QDict *qdict)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册