提交 c9a1b80d 编写于 作者: A AKASHI Takahiro 提交者: Linus Torvalds

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: b92df1de ("mm: page_alloc: skip over regions of invalid pfns where possible")
Link: http://lkml.kernel.org/r/20170303023745.9104-1-takahiro.akashi@linaro.orgSigned-off-by: NAKASHI Takahiro <takahiro.akashi@linaro.org>
Cc: Paul Burton <paul.burton@imgtec.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 46aa6a30
...@@ -1118,6 +1118,9 @@ unsigned long __init_memblock memblock_next_valid_pfn(unsigned long pfn, ...@@ -1118,6 +1118,9 @@ unsigned long __init_memblock memblock_next_valid_pfn(unsigned long pfn,
} }
} while (left < right); } while (left < right);
if (right == type->cnt)
return max_pfn;
else
return min(PHYS_PFN(type->regions[right].base), max_pfn); return min(PHYS_PFN(type->regions[right].base), max_pfn);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册