diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2021-08-06 11:31:11 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2021-08-06 11:31:11 -0700 |
commit | cb407fc81d68f3a61e82eda4e7f9421e67f8aece (patch) | |
tree | 17dfdf186d6f124a111696ce621d87b6ca75acc2 /arch | |
parent | 894d6f401b21865962aba776ecaa918b2f0abaa6 (diff) | |
parent | 6aa32467299e9e12280a6aec9dbc21bf2db830b0 (diff) | |
download | linux-cb407fc81d68f3a61e82eda4e7f9421e67f8aece.tar.bz2 |
Merge tag 'mips-fixes_5.14_1' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux
Pull MIPS fix from Thomas Bogendoerfer:
"Fix PMD accounting change"
* tag 'mips-fixes_5.14_1' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux:
MIPS: check return value of pgtable_pmd_page_ctor
Diffstat (limited to 'arch')
-rw-r--r-- | arch/mips/include/asm/pgalloc.h | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h index 4b2567d6b2df..c7925d0e9874 100644 --- a/arch/mips/include/asm/pgalloc.h +++ b/arch/mips/include/asm/pgalloc.h @@ -58,15 +58,20 @@ do { \ static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address) { - pmd_t *pmd = NULL; + pmd_t *pmd; struct page *pg; - pg = alloc_pages(GFP_KERNEL | __GFP_ACCOUNT, PMD_ORDER); - if (pg) { - pgtable_pmd_page_ctor(pg); - pmd = (pmd_t *)page_address(pg); - pmd_init((unsigned long)pmd, (unsigned long)invalid_pte_table); + pg = alloc_pages(GFP_KERNEL_ACCOUNT, PMD_ORDER); + if (!pg) + return NULL; + + if (!pgtable_pmd_page_ctor(pg)) { + __free_pages(pg, PMD_ORDER); + return NULL; } + + pmd = (pmd_t *)page_address(pg); + pmd_init((unsigned long)pmd, (unsigned long)invalid_pte_table); return pmd; } |