memblock: add limit checking to memblock_virt_alloc
authorYinghai Lu <[email protected]>
Wed, 29 Jan 2014 22:05:52 +0000 (14:05 -0800)
committerLinus Torvalds <[email protected]>
Thu, 30 Jan 2014 00:22:40 +0000 (16:22 -0800)
In original bootmem wrapper for memblock, we have limit checking.

Add it to memblock_virt_alloc, to address arm and x86 booting crash.

Signed-off-by: Yinghai Lu <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
Reported-by: Kevin Hilman <[email protected]>
Tested-by: Kevin Hilman <[email protected]>
Reported-by: Olof Johansson <[email protected]>
Tested-by: Olof Johansson <[email protected]>
Reported-by: Konrad Rzeszutek Wilk <[email protected]>
Tested-by: Konrad Rzeszutek Wilk <[email protected]>
Cc: Dave Hansen <[email protected]>
Cc: Santosh Shilimkar <[email protected]>
Cc: "Strashko, Grygorii" <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
mm/memblock.c

index 87d21a6ff63c5730a2708414b6054a139b77cdf1..39a31e7f004505991e37219bdb1e17f571efb933 100644 (file)
@@ -1077,6 +1077,9 @@ static void * __init memblock_virt_alloc_internal(
        if (!align)
                align = SMP_CACHE_BYTES;
 
+       if (max_addr > memblock.current_limit)
+               max_addr = memblock.current_limit;
+
 again:
        alloc = memblock_find_in_range_node(size, align, min_addr, max_addr,
                                            nid);