From 7f5d9b206d1e86425faa5b84b551068bf044b823 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Thu, 26 Mar 2020 10:41:21 +0100 Subject: [PATCH] object-add: don't create return value if failed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No need to return an empty value from object-add (it would also leak if the command failed). While at it, remove the "if" around object_unref since object_unref handles NULL arguments just fine. Reported-by: Marc-André Lureau Message-Id: <20200325184723.2029630-4-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- qom/qom-qmp-cmds.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/qom/qom-qmp-cmds.c b/qom/qom-qmp-cmds.c index 435193b036..e47ebe8ed1 100644 --- a/qom/qom-qmp-cmds.c +++ b/qom/qom-qmp-cmds.c @@ -285,10 +285,7 @@ void qmp_object_add(QDict *qdict, QObject **ret_data, Error **errp) v = qobject_input_visitor_new(QOBJECT(qdict)); obj = user_creatable_add_type(type, id, qdict, v, errp); visit_free(v); - if (obj) { - object_unref(obj); - } - *ret_data = QOBJECT(qdict_new()); + object_unref(obj); } void qmp_object_del(const char *id, Error **errp)