summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYinghai Lu <yinghai@kernel.org>2010-12-03 01:33:49 +0100
committerjames toy <toyj@union.edu>2010-12-03 01:33:49 +0100
commitcf501631265a30cc625fb2b690c085b3ab00f1e4 (patch)
tree9943fea83aed9d2c0784b4de65e920aa5a59483a
parentfaa665ceaa3c76e3344f49cf17401246da01feb9 (diff)
Make sure two callers have right inputs. and add print warning to catch
other offending callers. Signed-off-by: Yinghai Lu <yinghai@kernel.org> Suggested-by: Andrew Morton <akpm@linux-foundation.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Ingo Molnar <mingo@elte.hu> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: "H. Peter Anvin" <hpa@zytor.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
-rw-r--r--mm/memblock.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/mm/memblock.c b/mm/memblock.c
index bdba245d8afd..9f46cf9a98b7 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -106,7 +106,7 @@ static phys_addr_t __init_memblock memblock_find_region(phys_addr_t start, phys_
long j;
/* In case, huge size is requested */
- if (end < size)
+ if (WARN_ONCE(end < size, "memblock_find_region: wrong range [%#llx-%#llx] size %#llx", start, end, size))
return MEMBLOCK_ERROR;
base = memblock_align_down((end - size), align);
@@ -152,14 +152,14 @@ static phys_addr_t __init_memblock memblock_find_base(phys_addr_t size,
phys_addr_t memblocksize = memblock.memory.regions[i].size;
phys_addr_t bottom, top, found;
- if (memblocksize < size)
- continue;
if ((memblockbase + memblocksize) <= start)
break;
bottom = max(memblockbase, start);
top = min(memblockbase + memblocksize, end);
if (bottom >= top)
continue;
+ if ((top - bottom) < size)
+ continue;
found = memblock_find_region(bottom, top, size, align);
if (found != MEMBLOCK_ERROR)
return found;
@@ -547,7 +547,7 @@ static phys_addr_t __init memblock_alloc_nid_region(struct memblock_region *mp,
int this_nid;
this_end = memblock_nid_range(start, end, &this_nid);
- if (this_nid == nid) {
+ if (this_nid == nid && (this_end - start) >= size) {
phys_addr_t ret = memblock_find_region(start, this_end, size, align);
if (ret != MEMBLOCK_ERROR &&
memblock_add_region(&memblock.reserved, ret, size) >= 0)