From: AKASHI Takahiro <takahiro.akashi@xxxxxxxxxx> Subject: mm/memblock.c: fix memblock_next_valid_pfn() Obviously, we should not access memblock.memory.regions[right] if 'right' is outside of [0..memblock.memory.cnt>. Fixes: b92df1de5d28 ("mm: page_alloc: skip over regions of invalid pfns where possible") Link: http://lkml.kernel.org/r/20170303023745.9104-1-takahiro.akashi@xxxxxxxxxx Signed-off-by: AKASHI Takahiro <takahiro.akashi@xxxxxxxxxx> Cc: Paul Burton <paul.burton@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/memblock.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff -puN mm/memblock.c~memblock-fix-memblock_next_valid_pfn mm/memblock.c --- a/mm/memblock.c~memblock-fix-memblock_next_valid_pfn +++ a/mm/memblock.c @@ -1118,7 +1118,10 @@ unsigned long __init_memblock memblock_n } } while (left < right); - return min(PHYS_PFN(type->regions[right].base), max_pfn); + if (right == type->cnt) + return max_pfn; + else + return min(PHYS_PFN(type->regions[right].base), max_pfn); } /** _ -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html