]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
numa: Fix memory leak in numa_set_mem_node_id()
authorBharata B Rao <bharata@linux.vnet.ibm.com>
Thu, 9 Jul 2015 15:27:36 +0000 (20:57 +0530)
committerEduardo Habkost <ehabkost@redhat.com>
Wed, 15 Jul 2015 19:57:50 +0000 (16:57 -0300)
Fix a memory leak in numa_set_mem_node_id().

Signed-off-by: Bharata B Rao <bharata@linux.vnet.com>
Reported-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
numa.c

diff --git a/numa.c b/numa.c
index 3c8005913f2aa678bf2e05a2554e350afa4390c2..402804bdf499c08bb88490c44732d894e3b84923 100644 (file)
--- a/numa.c
+++ b/numa.c
@@ -54,7 +54,7 @@ NodeInfo numa_info[MAX_NODES];
 
 void numa_set_mem_node_id(ram_addr_t addr, uint64_t size, uint32_t node)
 {
-    struct numa_addr_range *range = g_malloc0(sizeof(*range));
+    struct numa_addr_range *range;
 
     /*
      * Memory-less nodes can come here with 0 size in which case,
@@ -64,6 +64,7 @@ void numa_set_mem_node_id(ram_addr_t addr, uint64_t size, uint32_t node)
         return;
     }
 
+    range = g_malloc0(sizeof(*range));
     range->mem_start = addr;
     range->mem_end = addr + size - 1;
     QLIST_INSERT_HEAD(&numa_info[node].addr, range, entry);