From b0e90181e4d7244a9466447703acdb2cdd7abdaa Mon Sep 17 00:00:00 2001 From: Chen Fan Date: Mon, 18 Aug 2014 14:46:33 +0800 Subject: query-memdev: fix potential memory leaks Signed-off-by: Chen Fan Reviewed-by: Peter Crosthwaite Reviewed-by: Hu Tao Signed-off-by: Michael Tokarev --- numa.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/numa.c b/numa.c index c78cec9..aa772aa 100644 --- a/numa.c +++ b/numa.c @@ -318,10 +318,11 @@ void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner, static int query_memdev(Object *obj, void *opaque) { MemdevList **list = opaque; + MemdevList *m = NULL; Error *err = NULL; if (object_dynamic_cast(obj, TYPE_MEMORY_BACKEND)) { - MemdevList *m = g_malloc0(sizeof(*m)); + m = g_malloc0(sizeof(*m)); m->value = g_malloc0(sizeof(*m->value)); @@ -369,6 +370,9 @@ static int query_memdev(Object *obj, void *opaque) return 0; error: + g_free(m->value); + g_free(m); + return -1; } -- cgit v1.1