Skip to content

Commit

Permalink
memblock: Make MEMBLOCK_ERROR be 0
Browse files Browse the repository at this point in the history
And ensure we don't hand out 0 as a valid allocation. We put the
low limit at PAGE_SIZE arbitrarily.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
  • Loading branch information
Benjamin Herrenschmidt committed Aug 5, 2010
1 parent 37d8d4b commit 25818f0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/linux/memblock.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <asm/memblock.h>

#define INIT_MEMBLOCK_REGIONS 128
#define MEMBLOCK_ERROR (~(phys_addr_t)0)
#define MEMBLOCK_ERROR 0

struct memblock_region {
phys_addr_t base;
Expand Down
6 changes: 6 additions & 0 deletions mm/memblock.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ static phys_addr_t __init memblock_find_region(phys_addr_t start, phys_addr_t en
phys_addr_t base, res_base;
long j;

/* Prevent allocations returning 0 as it's also used to
* indicate an allocation failure
*/
if (start == 0)
start = PAGE_SIZE;

base = memblock_align_down((end - size), align);
while (start <= base) {
j = memblock_overlaps_region(&memblock.reserved, base, size);
Expand Down

0 comments on commit 25818f0

Please sign in to comment.