diff options
Diffstat (limited to 'mm/memblock.c')
-rw-r--r-- | mm/memblock.c | 8 |
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) |