sparc: add checks for the return value of memblock_alloc*()
[linux] / arch / sparc / kernel / smp_64.c
index f45d876..a8275fe 100644 (file)
@@ -1628,6 +1628,8 @@ static void __init pcpu_populate_pte(unsigned long addr)
                pud_t *new;
 
                new = memblock_alloc_from(PAGE_SIZE, PAGE_SIZE, PAGE_SIZE);
+               if (!new)
+                       goto err_alloc;
                pgd_populate(&init_mm, pgd, new);
        }
 
@@ -1636,6 +1638,8 @@ static void __init pcpu_populate_pte(unsigned long addr)
                pmd_t *new;
 
                new = memblock_alloc_from(PAGE_SIZE, PAGE_SIZE, PAGE_SIZE);
+               if (!new)
+                       goto err_alloc;
                pud_populate(&init_mm, pud, new);
        }
 
@@ -1644,8 +1648,16 @@ static void __init pcpu_populate_pte(unsigned long addr)
                pte_t *new;
 
                new = memblock_alloc_from(PAGE_SIZE, PAGE_SIZE, PAGE_SIZE);
+               if (!new)
+                       goto err_alloc;
                pmd_populate_kernel(&init_mm, pmd, new);
        }
+
+       return;
+
+err_alloc:
+       panic("%s: Failed to allocate %lu bytes align=%lx from=%lx\n",
+             __func__, PAGE_SIZE, PAGE_SIZE, PAGE_SIZE);
 }
 
 void __init setup_per_cpu_areas(void)