Skip to content

Commit 98398c3

Browse files
Jianguo Wutorvalds
authored andcommitted
mm/hugetlb: check for pte NULL pointer in __page_check_address()
In __page_check_address(), if address's pud is not present, huge_pte_offset() will return NULL, we should check the return value. Signed-off-by: Jianguo Wu <wujianguo@huawei.com> Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> Cc: Mel Gorman <mgorman@suse.de> Cc: qiuxishi <qiuxishi@huawei.com> Cc: Hanjun Guo <guohanjun@huawei.com> Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 7ac1815 commit 98398c3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

mm/rmap.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,11 @@ pte_t *__page_check_address(struct page *page, struct mm_struct *mm,
600600
spinlock_t *ptl;
601601

602602
if (unlikely(PageHuge(page))) {
603+
/* when pud is not present, pte will be NULL */
603604
pte = huge_pte_offset(mm, address);
605+
if (!pte)
606+
return NULL;
607+
604608
ptl = huge_pte_lockptr(page_hstate(page), mm, pte);
605609
goto check;
606610
}

0 commit comments

Comments
 (0)