memblock: Make MEMBLOCK_ERROR be 0
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>
Wed, 28 Jul 2010 05:25:10 +0000 (15:25 +1000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Thu, 5 Aug 2010 02:56:30 +0000 (12:56 +1000)
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>
include/linux/memblock.h
mm/memblock.c

index 1a9c29cc92fafd6a4ee1a206a36631b1865f558d..dfa64494ced1acbd0a5fa4997fb117fb523e2423 100644 (file)
@@ -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;
index 85cfa1d3ab28b91ecf350b0aa6e668f13a08a8c1..cb520df2a414a7bfd3fecf41d0116d44a466272a 100644 (file)
@@ -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);