diff options
author | Chen Fan <chen.fan.fnst@cn.fujitsu.com> | 2014-08-18 14:46:33 +0800 |
---|---|---|
committer | Michael Tokarev <mjt@tls.msk.ru> | 2014-09-02 22:38:16 +0400 |
commit | b0e90181e4d7244a9466447703acdb2cdd7abdaa (patch) | |
tree | d3cb0cc7dbb9482199e33ab509f820849fd6beef | |
parent | 622fb504c402cc222f6c4b6f292d402c4d78a86e (diff) | |
download | hqemu-b0e90181e4d7244a9466447703acdb2cdd7abdaa.zip hqemu-b0e90181e4d7244a9466447703acdb2cdd7abdaa.tar.gz |
query-memdev: fix potential memory leaks
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-- | numa.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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; } |