aboutsummaryrefslogtreecommitdiffstats
path: root/mm/page_alloc.c
diff options
context:
space:
mode:
authorMike Rapoport <rppt@linux.ibm.com>2019-03-05 18:46:43 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2019-03-06 00:07:18 -0500
commit23a7052a5db478bdacf45bea55e6f50171f5eede (patch)
tree19a6113acea0e6a287e4653f365d8b5ff2780df6 /mm/page_alloc.c
parent8ef5cbde6dafce8f30edb53f87cb485ceace63df (diff)
mm/page_alloc.c: check return value of memblock_alloc_node_nopanic()
There are two early memory allocations that use memblock_alloc_node_nopanic() and do not check its return value. While this happens very early during boot and chances that the allocation will fail are diminishing, it is still worth to have proper checks for the allocation errors. Link: http://lkml.kernel.org/r/1547734941-944-1-git-send-email-rppt@linux.ibm.com Signed-off-by: Mike Rapoport <rppt@linux.ibm.com> Reviewed-by: William Kucharski <william.kucharski@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/page_alloc.c')
-rw-r--r--mm/page_alloc.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index ec250453f5e8..11a5f50efd97 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -6431,10 +6431,14 @@ static void __ref setup_usemap(struct pglist_data *pgdat,
6431{ 6431{
6432 unsigned long usemapsize = usemap_size(zone_start_pfn, zonesize); 6432 unsigned long usemapsize = usemap_size(zone_start_pfn, zonesize);
6433 zone->pageblock_flags = NULL; 6433 zone->pageblock_flags = NULL;
6434 if (usemapsize) 6434 if (usemapsize) {
6435 zone->pageblock_flags = 6435 zone->pageblock_flags =
6436 memblock_alloc_node_nopanic(usemapsize, 6436 memblock_alloc_node_nopanic(usemapsize,
6437 pgdat->node_id); 6437 pgdat->node_id);
6438 if (!zone->pageblock_flags)
6439 panic("Failed to allocate %ld bytes for zone %s pageblock flags on node %d\n",
6440 usemapsize, zone->name, pgdat->node_id);
6441 }
6438} 6442}
6439#else 6443#else
6440static inline void setup_usemap(struct pglist_data *pgdat, struct zone *zone, 6444static inline void setup_usemap(struct pglist_data *pgdat, struct zone *zone,
@@ -6664,6 +6668,9 @@ static void __ref alloc_node_mem_map(struct pglist_data *pgdat)
6664 end = ALIGN(end, MAX_ORDER_NR_PAGES); 6668 end = ALIGN(end, MAX_ORDER_NR_PAGES);
6665 size = (end - start) * sizeof(struct page); 6669 size = (end - start) * sizeof(struct page);
6666 map = memblock_alloc_node_nopanic(size, pgdat->node_id); 6670 map = memblock_alloc_node_nopanic(size, pgdat->node_id);
6671 if (!map)
6672 panic("Failed to allocate %ld bytes for node %d memory map\n",
6673 size, pgdat->node_id);
6667 pgdat->node_mem_map = map + offset; 6674 pgdat->node_mem_map = map + offset;
6668 } 6675 }
6669 pr_debug("%s: node %d, pgdat %08lx, node_mem_map %08lx\n", 6676 pr_debug("%s: node %d, pgdat %08lx, node_mem_map %08lx\n",