[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [PATCH] qom-qmp-cmds: Fix another memory leak in qmp_object_add()

From: Chenqun (kuhn)
Subject: RE: [PATCH] qom-qmp-cmds: Fix another memory leak in qmp_object_add()
Date: Tue, 17 Mar 2020 10:15:39 +0000

>-----Original Message-----
>From: Qemu-devel [mailto:qemu-devel-
>bounces+kuhn.chenqun=address@hidden] On Behalf Of Markus
>Sent: Tuesday, March 17, 2020 5:23 PM
>To: address@hidden
>Cc: Kevin Wolf <address@hidden>; address@hidden;
>address@hidden; address@hidden
>Subject: [PATCH] qom-qmp-cmds: Fix another memory leak in
>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 <address@hidden>
>Signed-off-by: Markus Armbruster <address@hidden>
Hi,  Markus

        Looks like the same patch that has been reported already here:

Maybe we should initialize ret_data in xen-block to avoid a possible 
uninitialized error ?

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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]