Skip to content

Commit

Permalink
powerpc/mm/hugetlb: Fix kernel crash if we fail to allocate page tabl…
Browse files Browse the repository at this point in the history
…e caches

We only check for hugetlb allocations, because with hugetlb we do conditional
registration. For PGD/PUD/PMD levels we register them always in
pgtable_cache_init.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
  • Loading branch information
Aneesh Kumar K.V authored and Michael Ellerman committed Jul 4, 2019
1 parent 2230ebf commit 5d49275
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion arch/powerpc/mm/hugetlbpage.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,17 @@ static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp,
num_hugepd = 1;
}

if (!cachep) {
WARN_ONCE(1, "No page table cache created for hugetlb tables");
return -ENOMEM;
}

new = kmem_cache_alloc(cachep, pgtable_gfp_flags(mm, GFP_KERNEL));

BUG_ON(pshift > HUGEPD_SHIFT_MASK);
BUG_ON((unsigned long)new & HUGEPD_SHIFT_MASK);

if (! new)
if (!new)
return -ENOMEM;

/*
Expand Down

0 comments on commit 5d49275

Please sign in to comment.