Skip to contentSkip to conversation

sparsemem fix for sparse_index_init

PATCH New Bob Picco 1 participant 1 message Aug 22, 2005

Subsystems (2)
lore
Share & tools
lore

Bob Picco

author
#0 lore raw

PATCH 1/1 sparsemem fix for sparse_index_init

Andrew:

After reviewing recent SPARSEMEM+EXTREME changes for -mm, I spotted a memory leak issue. In sparse_index_init we must evaluate whether the root index is allocated before allocating, acquiring the lock and then checking whether the root is already allocated. An alternative would be in the error path doing a free_bootmem_node but this seems the more expensive method for boot time.

thanks,

bob

 mm/sparse.c |    3 +++
 1 files changed, 3 insertions(+)
mm/sparse.c +3 -0
Index: linux-2.6.13-rc6-mm1/mm/sparse.c
===================================================================
@@ -45,6 +45,9 @@ static int sparse_index_init(unsigned lo
 	struct mem_section *section;
 	int ret = 0;
 
+	if (mem_section[root])
+		return -EEXIST;
+
 	section = sparse_index_alloc(nid);
 	/*
 	 * This lock keeps two different sections from