[RFC V2 4/6] sh/mm: Stop using [p4d|pud|pmd]_ERROR()

From: Anshuman Khandual

Date: Tue Aug 11 2026 - 00:24:50 EST


Stop using [p4d|pud|pmd]_ERROR() in __get_pte_phys() as the pgtable entries
are known to be NULL and hence could not really be accessed.

Cc: Yoshinori Sato <ysato@xxxxxxxxxxxxxxxxxxxx>
Cc: Rich Felker <dalias@xxxxxxxx>
Cc: John Paul Adrian Glaubitz <glaubitz@xxxxxxxxxxxxxxxxxxx>
Cc: linux-sh@xxxxxxxxxxxxxxx
Cc: linux-kernel@xxxxxxxxxxxxxxx
Signed-off-by: Anshuman Khandual <anshuman.khandual@xxxxxxx>
---
arch/sh/mm/init.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c
index b3c7fd84ceb4..0bb8555568a4 100644
--- a/arch/sh/mm/init.c
+++ b/arch/sh/mm/init.c
@@ -58,22 +58,16 @@ static pte_t *__get_pte_phys(unsigned long addr)
}

p4d = p4d_alloc(NULL, pgd, addr);
- if (unlikely(!p4d)) {
- p4d_ERROR(*p4d);
+ if (unlikely(!p4d))
return NULL;
- }

pud = pud_alloc(NULL, p4d, addr);
- if (unlikely(!pud)) {
- pud_ERROR(*pud);
+ if (unlikely(!pud))
return NULL;
- }

pmd = pmd_alloc(NULL, pud, addr);
- if (unlikely(!pmd)) {
- pmd_ERROR(*pmd);
+ if (unlikely(!pmd))
return NULL;
- }

return pte_offset_kernel(pmd, addr);
}
--
2.43.0