From d3770de80d1637e89a051c9fa2ee784c615ca9c8 Mon Sep 17 00:00:00 2001 From: zhangtianyang Date: Thu, 22 May 2025 17:52:59 +0800 Subject: [PATCH] anolis: Loongarch:Fixed up panic cause by a NULL-pmd ANBZ: #21665 In some cases, pmd may be NULL and rely on NULL as the return value for processing, so it is necessary to determine this situation here Signed-off-by: zhangtianyang Signed-off-by: Juxin Gao --- arch/loongarch/mm/hugetlbpage.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/loongarch/mm/hugetlbpage.c b/arch/loongarch/mm/hugetlbpage.c index aca52c42e94e..fb09fb70661e 100644 --- a/arch/loongarch/mm/hugetlbpage.c +++ b/arch/loongarch/mm/hugetlbpage.c @@ -47,7 +47,8 @@ pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr, pmd = pmd_offset(pud, addr); } } - return pmd_none(pmdp_get(pmd)) ? NULL : (pte_t *) pmd; + + return (!pmd || pmd_none(pmdp_get(pmd))) ? NULL : (pte_t *) pmd; } int pmd_huge(pmd_t pmd) -- Gitee