Skip to contentSkip to conversation

mm/hugetlb: check for pte NULL pointer in __page_check_address()

PATCH In review Jianguo Wu 2 participants 3 messages Dec 16, 2013 – Dec 17, 2013

Subsystems (2)
lore
Share & tools
lore

Jianguo Wu

author
#0 lore raw

PATCH 1/1 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.

---
 mm/rmap.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
mm/rmap.c +4 -0
index 55c8b8d..068522d 100644
@@ -600,7 +600,11 @@ pte_t *__page_check_address(struct page *page, struct mm_struct *mm,
 	spinlock_t *ptl;
 
 	if (unlikely(PageHuge(page))) {
+		/* when pud is not present, pte will be NULL */
 		pte = huge_pte_offset(mm, address);
+		if (!pte)
+			return NULL;
+
 		ptl = huge_pte_lockptr(page_hstate(page), mm, pte);
 		goto check;
 	}
Signature · 8 lines
1.7.1


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
author
#2 lore raw

Hi Kirill,

Quoted 4 lines · Kirill A. Shutemov
Quoted 3 lines · Jianguo Wu

In __page_check_address(), if address's pud is not present, huge_pte_offset() will return NULL, we should check the return value.

Quoted 8 lines
Quoted 1 line

Looks okay to me.

Have you triggered a crash there? Or just spotted by reading the code?

By reading the code.

Thanks,
Jianguo Wu

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>