[linux-yocto] [PATCH 08/23] mm/hugetlb.c: add NULL check of return value of huge_pte_offset
Yang Shi
yang.shi at windriver.com
Wed Jul 30 19:16:12 PDT 2014
From: Naoya Horiguchi <n-horiguchi at ah.jp.nec.com>
commit a9af0c5dfdaf0b2e1a8bab7fbf6f29138947d534 upstream
huge_pte_offset() could return NULL, so we need NULL check to avoid
potential NULL pointer dereferences.
Signed-off-by: Naoya Horiguchi <n-horiguchi at ah.jp.nec.com>
Cc: Mel Gorman <mgorman at suse.de>
Cc: Sasha Levin <sasha.levin at oracle.com>
Cc: Kirill A. Shutemov <kirill.shutemov at linux.intel.com>
Cc: Aneesh Kumar K.V <aneesh.kumar at linux.vnet.ibm.com>
Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
Signed-off-by: Yang Shi <yang.shi at windriver.com>
---
mm/hugetlb.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 7b117a5..f2b821b 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -2692,7 +2692,8 @@ retry_avoidcopy:
BUG_ON(huge_pte_none(pte));
spin_lock(ptl);
ptep = huge_pte_offset(mm, address & huge_page_mask(h));
- if (likely(pte_same(huge_ptep_get(ptep), pte)))
+ if (likely(ptep &&
+ pte_same(huge_ptep_get(ptep), pte)))
goto retry_avoidcopy;
/*
* race occurs while re-acquiring page table
@@ -2736,7 +2737,7 @@ retry_avoidcopy:
*/
spin_lock(ptl);
ptep = huge_pte_offset(mm, address & huge_page_mask(h));
- if (likely(pte_same(huge_ptep_get(ptep), pte))) {
+ if (likely(ptep && pte_same(huge_ptep_get(ptep), pte))) {
ClearPagePrivate(new_page);
/* Break COW */
--
2.0.2
More information about the linux-yocto
mailing list