qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: hutao@cn.fujitsu.com, ehabkost@redhat.com, mst@redhat.com
Subject: [Qemu-devel] [PATCH] numa: Clean up query-memdev error handling, plug leak
Date: Fri, 20 Nov 2015 14:00:40 +0100	[thread overview]
Message-ID: <1448024440-31222-1-git-send-email-armbru@redhat.com> (raw)

qmp_query_memdev() doesn't fail.  Instead, it returns an empty list.
That's wrong.

Two error paths:

* When object_get_objects_root() returns null.  It never does, so
  simply drop the useless error handling.

* When query_memdev() fails.  This can happen, and the error to return
  is the one that query_memdev() currently leaks.  Passing the error
  from query_memdev() to qmp_query_memdev() isn't so simple, because
  object_child_foreach() is in the way.  Fixable, but I'd rather not
  try it in hard freeze.  Plug the leak, make up an error, and add a
  FIXME for the remaining work.

Screwed up in commit 76b5d85 "qmp: add query-memdev".

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 numa.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/numa.c b/numa.c
index fdfe294..a584e8e 100644
--- a/numa.c
+++ b/numa.c
@@ -568,6 +568,7 @@ static int query_memdev(Object *obj, void *opaque)
 
     return 0;
 error:
+    error_free(err);
     g_free(m->value);
     g_free(m);
 
@@ -576,15 +577,12 @@ error:
 
 MemdevList *qmp_query_memdev(Error **errp)
 {
-    Object *obj;
+    Object *obj = object_get_objects_root();
     MemdevList *list = NULL;
 
-    obj = object_get_objects_root();
-    if (obj == NULL) {
-        return NULL;
-    }
-
     if (object_child_foreach(obj, query_memdev, &list) != 0) {
+        /* FIXME propagate the error query_memdev() throws away */
+        error_setg(errp, "Unknown error");
         goto error;
     }
 
-- 
2.4.3

             reply	other threads:[~2015-11-20 13:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-20 13:00 Markus Armbruster [this message]
2015-11-20 14:19 ` [Qemu-devel] [PATCH] numa: Clean up query-memdev error handling, plug leak Eduardo Habkost
2015-11-20 14:57   ` Markus Armbruster
2015-11-20 15:20     ` Eduardo Habkost
2015-11-20 16:24       ` Markus Armbruster
2015-11-20 19:26         ` Eduardo Habkost
2015-11-20 19:44           ` Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1448024440-31222-1-git-send-email-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=hutao@cn.fujitsu.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).