>-----Original Message----- >From: Qemu-devel [mailto:qemu-devel- >bounces+kuhn.chenqun=huawei....@nongnu.org] On Behalf Of Markus >Armbruster >Sent: Tuesday, March 17, 2020 5:23 PM >To: qemu-devel@nongnu.org >Cc: Kevin Wolf <kw...@redhat.com>; pbonz...@redhat.com; >berra...@redhat.com; ehabk...@redhat.com >Subject: [PATCH] qom-qmp-cmds: Fix another memory leak in >qmp_object_add() > >When user_creatable_add_type() fails, qmp_object_add() returns both its >error and the usual empty QDict success value. The QMP core handles the >error, and ignores the success value, leaking it. Exposed by qmp-cmd-test >case /x86_64/qmp/object-add-without-props, and duly reported both by >ASan and valgrind. > >To plug the leak, set the success value only on success. > >Fixes: 5f07c4d60d091320186e7b0edaf9ed2cc16b2d1e >Cc: Kevin Wolf <kw...@redhat.com> >Signed-off-by: Markus Armbruster <arm...@redhat.com> >--- Hi, Markus
Looks like the same patch that has been reported already here: https://lists.gnu.org/archive/html/qemu-devel/2020-03/msg03928.html Maybe we should initialize ret_data in xen-block to avoid a possible uninitialized error ? Thanks. > qom/qom-qmp-cmds.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > >diff --git a/qom/qom-qmp-cmds.c b/qom/qom-qmp-cmds.c index >435193b036..6bd137ccbf 100644 >--- a/qom/qom-qmp-cmds.c >+++ b/qom/qom-qmp-cmds.c >@@ -287,8 +287,8 @@ void qmp_object_add(QDict *qdict, QObject >**ret_data, Error **errp) > visit_free(v); > if (obj) { > object_unref(obj); >+ *ret_data = QOBJECT(qdict_new()); > } >- *ret_data = QOBJECT(qdict_new()); > } > > void qmp_object_del(const char *id, Error **errp) >-- >2.21.1 >