]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
powerpc/mm: Handle page table allocation failures
authorAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Tue, 28 May 2019 05:36:24 +0000 (11:06 +0530)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
BugLink: https://bugs.launchpad.net/bugs/1839213
[ Upstream commit 2230ebf6e6dd0b7751e2921b40f6cfe34f09bb16 ]

This fixes kernel crash that arises due to not handling page table allocation
failures while allocating hugetlb page table.

Fixes: e2b3d202d1db ("powerpc: Switch 16GB and 16MB explicit hugepages to a different page table format")
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
arch/powerpc/mm/hugetlbpage.c

index 4a41d54bc8b88357c2f2b8028ae6d9f7029f3b5a..dc9d1b007124a84d6be81ee9de4cd727a71ecc52 100644 (file)
@@ -158,6 +158,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)
@@ -165,6 +167,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;
@@ -178,11 +182,15 @@ 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 >= HUGEPD_PUD_SHIFT) {
                        hpdp = (hugepd_t *)pu;
                } else {
                        pdshift = PMD_SHIFT;
                        pm = pmd_alloc(mm, pu, addr);
+                       if (!pm)
+                               return NULL;
                        hpdp = (hugepd_t *)pm;
                }
        }