Gitweb: http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=bbd0682596f7a434467ee551fee18d5f0b818539 Commit: bbd0682596f7a434467ee551fee18d5f0b818539 Parent: af0cd5a7c3cded50c25e98acd94912d17a0eb914 Author: WANG Cong <[EMAIL PROTECTED]> AuthorDate: Mon Dec 17 16:19:59 2007 -0800 Committer: Linus Torvalds <[EMAIL PROTECTED]> CommitDate: Mon Dec 17 19:28:16 2007 -0800
mm/sparse.c: improve the error handling for sparse_add_one_section() Improve the error handling for mm/sparse.c::sparse_add_one_section(). And I see no reason to check 'usemap' until holding the 'pgdat_resize_lock'. [EMAIL PROTECTED]: sparse_index_init() returns -EEXIST] Cc: Christoph Lameter <[EMAIL PROTECTED]> Acked-by: Dave Hansen <[EMAIL PROTECTED]> Cc: Rik van Riel <[EMAIL PROTECTED]> Acked-by: Yasunori Goto <[EMAIL PROTECTED]> Cc: Andy Whitcroft <[EMAIL PROTECTED]> Signed-off-by: WANG Cong <[EMAIL PROTECTED]> Signed-off-by: Geoff Levand <[EMAIL PROTECTED]> Signed-off-by: Andrew Morton <[EMAIL PROTECTED]> Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]> --- mm/sparse.c | 18 ++++++++++++------ 1 files changed, 12 insertions(+), 6 deletions(-) diff --git a/mm/sparse.c b/mm/sparse.c index d245e59..a2183cb 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -391,9 +391,17 @@ int sparse_add_one_section(struct zone *zone, unsigned long start_pfn, * no locking for this, because it does its own * plus, it does a kmalloc */ - sparse_index_init(section_nr, pgdat->node_id); + ret = sparse_index_init(section_nr, pgdat->node_id); + if (ret < 0 && ret != -EEXIST) + return ret; memmap = kmalloc_section_memmap(section_nr, pgdat->node_id, nr_pages); + if (!memmap) + return -ENOMEM; usemap = __kmalloc_section_usemap(); + if (!usemap) { + __kfree_section_memmap(memmap, nr_pages); + return -ENOMEM; + } pgdat_resize_lock(pgdat, &flags); @@ -403,18 +411,16 @@ int sparse_add_one_section(struct zone *zone, unsigned long start_pfn, goto out; } - if (!usemap) { - ret = -ENOMEM; - goto out; - } ms->section_mem_map |= SECTION_MARKED_PRESENT; ret = sparse_init_one_section(ms, section_nr, memmap, usemap); out: pgdat_resize_unlock(pgdat, &flags); - if (ret <= 0) + if (ret <= 0) { + kfree(usemap); __kfree_section_memmap(memmap, nr_pages); + } return ret; } #endif - To unsubscribe from this list: send the line "unsubscribe git-commits-head" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html