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>
This commit is contained in:
Chen Fan 2014-08-18 14:46:33 +08:00 committed by Michael Tokarev
parent 622fb504c4
commit b0e90181e4

6
numa.c
View File

@ -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;
}