mm/nobootmem.c: add return value check in __alloc_memory_core_early()
authorPhilipp Hachtmann <phacht@linux.vnet.ibm.com>
Thu, 23 Jan 2014 23:53:10 +0000 (15:53 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 24 Jan 2014 00:36:51 +0000 (16:36 -0800)
When memblock_reserve() fails because memblock.reserved.regions cannot
be resized, the caller (e.g.  alloc_bootmem()) is not informed of the
failed allocation.  Therefore alloc_bootmem() silently returns the same
pointer again and again.

This patch adds a check for the return value of memblock_reserve() in
__alloc_memory_core().

Signed-off-by: Philipp Hachtmann <phacht@linux.vnet.ibm.com>
Reviewed-by: Tejun Heo <tj@kernel.org>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Tang Chen <tangchen@cn.fujitsu.com>
Cc: Toshi Kani <toshi.kani@hp.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/nobootmem.c

index 19121ceb8874977310e0559ad0bf8488140d59b1..bb1a70cc97a7f165ebfbfd38c565c67acb8cb438 100644 (file)
@@ -45,7 +45,9 @@ static void * __init __alloc_memory_core_early(int nid, u64 size, u64 align,
        if (!addr)
                return NULL;
 
-       memblock_reserve(addr, size);
+       if (memblock_reserve(addr, size))
+               return NULL;
+
        ptr = phys_to_virt(addr);
        memset(ptr, 0, size);
        /*