summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChen Fan <chen.fan.fnst@cn.fujitsu.com>2014-08-18 14:46:35 +0800
committerMichael Tokarev <mjt@tls.msk.ru>2014-09-02 22:38:16 +0400
commitecaf54a052c357e0bacb93c3f178fed34e4821ec (patch)
treee91c8de8244ac41f8721dc142ddd361446f7cafb
parent976620ac4018db142d82cd42bb7774f40290ce7e (diff)
downloadqemu-ecaf54a052c357e0bacb93c3f178fed34e4821ec.zip
hmp: fix MemdevList memory leak
the memdev_list in hmp_info_memdev() is never freed. so we use existent method qapi_free_MemdevList() to free it. and also we can use qapi_free_MemdevList() to replace list loops to clean up the memdev list in error path. Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com> Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Reviewed-by: Hu Tao <hutao@cn.fujitsu.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
-rw-r--r--hmp.c2
-rw-r--r--numa.c9
2 files changed, 4 insertions, 7 deletions
diff --git a/hmp.c b/hmp.c
index ba40c75005..40a90dae70 100644
--- a/hmp.c
+++ b/hmp.c
@@ -1715,4 +1715,6 @@ void hmp_info_memdev(Monitor *mon, const QDict *qdict)
}
monitor_printf(mon, "\n");
+
+ qapi_free_MemdevList(memdev_list);
}
diff --git a/numa.c b/numa.c
index aa772aafad..f07149b12d 100644
--- a/numa.c
+++ b/numa.c
@@ -379,7 +379,7 @@ error:
MemdevList *qmp_query_memdev(Error **errp)
{
Object *obj;
- MemdevList *list = NULL, *m;
+ MemdevList *list = NULL;
obj = object_resolve_path("/objects", NULL);
if (obj == NULL) {
@@ -393,11 +393,6 @@ MemdevList *qmp_query_memdev(Error **errp)
return list;
error:
- while (list) {
- m = list;
- list = list->next;
- g_free(m->value);
- g_free(m);
- }
+ qapi_free_MemdevList(list);
return NULL;
}