diff mbox

[FIX] numa: Fix memory leak in numa_set_mem_node_id()

Message ID 1436455656-12601-1-git-send-email-bharata@linux.vnet.ibm.com
State New
Headers show

Commit Message

Bharata B Rao July 9, 2015, 3:27 p.m. UTC
Fix a memory leak in numa_set_mem_node_id().

Signed-off-by: Bharata B Rao <bharata@linux.vnet.com>
---
 numa.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Eduardo Habkost July 9, 2015, 3:36 p.m. UTC | #1
On Thu, Jul 09, 2015 at 08:57:36PM +0530, Bharata B Rao wrote:
> Fix a memory leak in numa_set_mem_node_id().
> 
> Signed-off-by: Bharata B Rao <bharata@linux.vnet.com>

Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>

Applied to the NUMA tree. Thanks!
diff mbox

Patch

diff --git a/numa.c b/numa.c
index 3c80059..402804b 100644
--- 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);