sparc: add checks for the return value of memblock_alloc*()
[linux] / arch / sparc / mm / init_64.c
index ef340e8..f2d70ff 100644 (file)
@@ -1809,6 +1809,8 @@ static unsigned long __ref kernel_map_range(unsigned long pstart,
 
                        new = memblock_alloc_from(PAGE_SIZE, PAGE_SIZE,
                                                  PAGE_SIZE);
+                       if (!new)
+                               goto err_alloc;
                        alloc_bytes += PAGE_SIZE;
                        pgd_populate(&init_mm, pgd, new);
                }
@@ -1822,6 +1824,8 @@ static unsigned long __ref kernel_map_range(unsigned long pstart,
                        }
                        new = memblock_alloc_from(PAGE_SIZE, PAGE_SIZE,
                                                  PAGE_SIZE);
+                       if (!new)
+                               goto err_alloc;
                        alloc_bytes += PAGE_SIZE;
                        pud_populate(&init_mm, pud, new);
                }
@@ -1836,6 +1840,8 @@ static unsigned long __ref kernel_map_range(unsigned long pstart,
                        }
                        new = memblock_alloc_from(PAGE_SIZE, PAGE_SIZE,
                                                  PAGE_SIZE);
+                       if (!new)
+                               goto err_alloc;
                        alloc_bytes += PAGE_SIZE;
                        pmd_populate_kernel(&init_mm, pmd, new);
                }
@@ -1855,6 +1861,11 @@ static unsigned long __ref kernel_map_range(unsigned long pstart,
        }
 
        return alloc_bytes;
+
+err_alloc:
+       panic("%s: Failed to allocate %lu bytes align=%lx from=%lx\n",
+             __func__, PAGE_SIZE, PAGE_SIZE, PAGE_SIZE);
+       return -ENOMEM;
 }
 
 static void __init flush_all_kernel_tsbs(void)