提交 9ca96b5d 编写于 作者: Y Yang Yingliang 提交者: Xie XiuQi

mm: fix out of bound when address of pfn is out of last region

hulk inclusion
category: performance
bugzilla: 11028
CVE: NA

-------------------------------------------------

For exampe, if we have 3 regions which is [a, b] [c, d] [e, f]
if address of pfn is bigger than the end address of last region,
we will increse early_region_idx to count of region, which is out
of bound of the regions. Fix this by check the early_region_idx if
equals count of region.
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Reviewed-by: Nzhong jiang <zhongjiang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 2768aeac
......@@ -1252,13 +1252,17 @@ unsigned long __init_memblock memblock_next_valid_pfn(unsigned long pfn)
if (pfn >= start_pfn && pfn < end_pfn)
return pfn;
early_region_idx++;
/* try slow path */
if (++early_region_idx == type->cnt)
goto slow_path;
next_start_pfn = PFN_DOWN(regions[early_region_idx].base);
if (pfn >= end_pfn && pfn <= next_start_pfn)
return next_start_pfn;
}
slow_path:
/* slow path, do the binary searching */
do {
mid = (right + left) / 2;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册