提交 ecaf54a0 编写于 作者: C Chen Fan 提交者: Michael Tokarev

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: NChen Fan <chen.fan.fnst@cn.fujitsu.com>
Reviewed-by: NPeter Crosthwaite <peter.crosthwaite@xilinx.com>
Reviewed-by: NHu Tao <hutao@cn.fujitsu.com>
Signed-off-by: NMichael Tokarev <mjt@tls.msk.ru>
上级 976620ac
......@@ -1715,4 +1715,6 @@ void hmp_info_memdev(Monitor *mon, const QDict *qdict)
}
monitor_printf(mon, "\n");
qapi_free_MemdevList(memdev_list);
}
......@@ -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;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册