[Top][All Lists]

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

[Qemu-devel] [PATCH] numa: Clean up query-memdev error handling, plug le

From: Markus Armbruster
Subject: [Qemu-devel] [PATCH] numa: Clean up query-memdev error handling, plug leak
Date: Fri, 20 Nov 2015 14:00:40 +0100

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 <address@hidden>
 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_free(err);
@@ -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;

reply via email to

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