[RFC PATCH 1/3] powerpc/mm: Handle page table allocation failures

Tyrel Datwyler tyreld at linux.vnet.ibm.com
Wed May 15 08:35:39 AEST 2019


On 05/14/2019 07:50 AM, Aneesh Kumar K.V wrote:
> This fixes the below crash that arises due to not handling page table allocation
> failures while allocating hugetlb page table.

Was there supposed to be a oops stack trace attached here in the commit log?

-Tyrel

> 
> Fixes: e2b3d202d1db ("powerpc: Switch 16GB and 16MB explicit hugepages to a different page table format")
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar at linux.ibm.com>
> ---
>  arch/powerpc/mm/hugetlbpage.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c
> index c5c9ff2d7afc..ae9d71da5219 100644
> --- a/arch/powerpc/mm/hugetlbpage.c
> +++ b/arch/powerpc/mm/hugetlbpage.c
> @@ -130,6 +130,8 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr, unsigned long sz
>  	} else {
>  		pdshift = PUD_SHIFT;
>  		pu = pud_alloc(mm, pg, addr);
> +		if (!pu)
> +			return NULL;
>  		if (pshift == PUD_SHIFT)
>  			return (pte_t *)pu;
>  		else if (pshift > PMD_SHIFT) {
> @@ -138,6 +140,8 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr, unsigned long sz
>  		} else {
>  			pdshift = PMD_SHIFT;
>  			pm = pmd_alloc(mm, pu, addr);
> +			if (!pm)
> +				return NULL;
>  			if (pshift == PMD_SHIFT)
>  				/* 16MB hugepage */
>  				return (pte_t *)pm;
> @@ -154,12 +158,16 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr, unsigned long sz
>  	} else {
>  		pdshift = PUD_SHIFT;
>  		pu = pud_alloc(mm, pg, addr);
> +		if (!pu)
> +			return NULL;
>  		if (pshift >= PUD_SHIFT) {
>  			ptl = pud_lockptr(mm, pu);
>  			hpdp = (hugepd_t *)pu;
>  		} else {
>  			pdshift = PMD_SHIFT;
>  			pm = pmd_alloc(mm, pu, addr);
> +			if (!pm)
> +				return NULL;
>  			ptl = pmd_lockptr(mm, pm);
>  			hpdp = (hugepd_t *)pm;
>  		}
> 



More information about the Linuxppc-dev mailing list