summaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorAKASHI Takahiro <takahiro.akashi@linaro.org>2017-03-10 01:17:17 +0100
committerLinus Torvalds <torvalds@linux-foundation.org>2017-03-10 02:01:10 +0100
commitc9a1b80daeb50e39f21fd7e62f7224f317ac85f0 (patch)
treeba7d2f2a78fafcef679688d2d059797fee7a1053 /mm
parentuserfaultfd: selftest: vm: allow to build in vm/ directory (diff)
downloadlinux-c9a1b80daeb50e39f21fd7e62f7224f317ac85f0.tar.xz
linux-c9a1b80daeb50e39f21fd7e62f7224f317ac85f0.zip
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@linaro.org Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Cc: Paul Burton <paul.burton@imgtec.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/memblock.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/mm/memblock.c b/mm/memblock.c
index b64b47803e52..696f06d17c4e 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -1118,7 +1118,10 @@ unsigned long __init_memblock memblock_next_valid_pfn(unsigned long pfn,
}
} 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);
}
/**