aboutsummaryrefslogtreecommitdiffstats
path: root/mm/sparse.c
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2007-12-21 06:21:08 -0500
committerPaul Mackerras <paulus@samba.org>2007-12-21 06:21:08 -0500
commitc2a7dcad9f0d92d7a96e735abb8bec7b9c621536 (patch)
treebf9b20fdd5ab07e5b0e4e0b95c6a3dbab1005cb9 /mm/sparse.c
parent373a6da165ac3012a74fd072da340eabca55d031 (diff)
parentea67db4cdbbf7f4e74150e71da0984e25121f500 (diff)
Merge branch 'linux-2.6'
Diffstat (limited to 'mm/sparse.c')
-rw-r--r--mm/sparse.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/mm/sparse.c b/mm/sparse.c
index e06f514fe04f..a2183cb5d524 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -83,6 +83,8 @@ static int __meminit sparse_index_init(unsigned long section_nr, int nid)
83 return -EEXIST; 83 return -EEXIST;
84 84
85 section = sparse_index_alloc(nid); 85 section = sparse_index_alloc(nid);
86 if (!section)
87 return -ENOMEM;
86 /* 88 /*
87 * This lock keeps two different sections from 89 * This lock keeps two different sections from
88 * reallocating for the same index 90 * reallocating for the same index
@@ -389,9 +391,17 @@ int sparse_add_one_section(struct zone *zone, unsigned long start_pfn,
389 * no locking for this, because it does its own 391 * no locking for this, because it does its own
390 * plus, it does a kmalloc 392 * plus, it does a kmalloc
391 */ 393 */
392 sparse_index_init(section_nr, pgdat->node_id); 394 ret = sparse_index_init(section_nr, pgdat->node_id);
395 if (ret < 0 && ret != -EEXIST)
396 return ret;
393 memmap = kmalloc_section_memmap(section_nr, pgdat->node_id, nr_pages); 397 memmap = kmalloc_section_memmap(section_nr, pgdat->node_id, nr_pages);
398 if (!memmap)
399 return -ENOMEM;
394 usemap = __kmalloc_section_usemap(); 400 usemap = __kmalloc_section_usemap();
401 if (!usemap) {
402 __kfree_section_memmap(memmap, nr_pages);
403 return -ENOMEM;
404 }
395 405
396 pgdat_resize_lock(pgdat, &flags); 406 pgdat_resize_lock(pgdat, &flags);
397 407
@@ -401,18 +411,16 @@ int sparse_add_one_section(struct zone *zone, unsigned long start_pfn,
401 goto out; 411 goto out;
402 } 412 }
403 413
404 if (!usemap) {
405 ret = -ENOMEM;
406 goto out;
407 }
408 ms->section_mem_map |= SECTION_MARKED_PRESENT; 414 ms->section_mem_map |= SECTION_MARKED_PRESENT;
409 415
410 ret = sparse_init_one_section(ms, section_nr, memmap, usemap); 416 ret = sparse_init_one_section(ms, section_nr, memmap, usemap);
411 417
412out: 418out:
413 pgdat_resize_unlock(pgdat, &flags); 419 pgdat_resize_unlock(pgdat, &flags);
414 if (ret <= 0) 420 if (ret <= 0) {
421 kfree(usemap);
415 __kfree_section_memmap(memmap, nr_pages); 422 __kfree_section_memmap(memmap, nr_pages);
423 }
416 return ret; 424 return ret;
417} 425}
418#endif 426#endif