Skip to content

Commit

Permalink
mm/nobootmem.c: add return value check in __alloc_memory_core_early()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Philipp Hachtmann authored and Linus Torvalds committed Jan 24, 2014
1 parent d644163 commit 87379ec
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mm/nobootmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
/*
Expand Down

0 comments on commit 87379ec

Please sign in to comment.