Commit 46a66eec authored by Mike Kravetz's avatar Mike Kravetz Committed by Linus Torvalds

[PATCH] sparsemem interaction with memory add bug fixes

This patch fixes two bugs with the way sparsemem interacts with memory add.
They are:

- memory leak if memmap for section already exists

- calling alloc_bootmem_node() after boot

These bugs were discovered and a first cut at the fixes were provided by
Arnd Bergmann <arnd@arndb.de> and Joel Schopp <jschopp@us.ibm.com>.
Signed-off-by: default avatarMike Kravetz <kravetz@us.ibm.com>
Signed-off-by: default avatarJoel Schopp <jschopp@austin.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 2c43630f
...@@ -32,6 +32,9 @@ static struct mem_section *sparse_index_alloc(int nid) ...@@ -32,6 +32,9 @@ static struct mem_section *sparse_index_alloc(int nid)
unsigned long array_size = SECTIONS_PER_ROOT * unsigned long array_size = SECTIONS_PER_ROOT *
sizeof(struct mem_section); sizeof(struct mem_section);
if (system_state == SYSTEM_RUNNING)
section = kmalloc_node(array_size, GFP_KERNEL, nid);
else
section = alloc_bootmem_node(NODE_DATA(nid), array_size); section = alloc_bootmem_node(NODE_DATA(nid), array_size);
if (section) if (section)
...@@ -281,9 +284,9 @@ int sparse_add_one_section(struct zone *zone, unsigned long start_pfn, ...@@ -281,9 +284,9 @@ int sparse_add_one_section(struct zone *zone, unsigned long start_pfn,
ret = sparse_init_one_section(ms, section_nr, memmap); ret = sparse_init_one_section(ms, section_nr, memmap);
if (ret <= 0)
__kfree_section_memmap(memmap, nr_pages);
out: out:
pgdat_resize_unlock(pgdat, &flags); pgdat_resize_unlock(pgdat, &flags);
if (ret <= 0)
__kfree_section_memmap(memmap, nr_pages);
return ret; return ret;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment