aboutsummaryrefslogtreecommitdiffstats
path: root/mm/hugetlb.c
diff options
context:
space:
mode:
authorNaoya Horiguchi <n-horiguchi@ah.jp.nec.com>2014-04-07 18:36:54 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-04-07 19:35:49 -0400
commita9af0c5dfdaf0b2e1a8bab7fbf6f29138947d534 (patch)
tree2de13aa7095ee0b4aa8a7d47d9d89817a06a52a6 /mm/hugetlb.c
parent87c1b497c299e48e681f041de4dd6ce4831aaf75 (diff)
mm/hugetlb.c: add NULL check of return value of huge_pte_offset
huge_pte_offset() could return NULL, so we need NULL check to avoid potential NULL pointer dereferences. Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> Cc: Mel Gorman <mgorman@suse.de> Cc: Sasha Levin <sasha.levin@oracle.com> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/hugetlb.c')
-rw-r--r--mm/hugetlb.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 7c02b9dadfb0..6cddfadaba03 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -2690,7 +2690,8 @@ retry_avoidcopy:
2690 BUG_ON(huge_pte_none(pte)); 2690 BUG_ON(huge_pte_none(pte));
2691 spin_lock(ptl); 2691 spin_lock(ptl);
2692 ptep = huge_pte_offset(mm, address & huge_page_mask(h)); 2692 ptep = huge_pte_offset(mm, address & huge_page_mask(h));
2693 if (likely(pte_same(huge_ptep_get(ptep), pte))) 2693 if (likely(ptep &&
2694 pte_same(huge_ptep_get(ptep), pte)))
2694 goto retry_avoidcopy; 2695 goto retry_avoidcopy;
2695 /* 2696 /*
2696 * race occurs while re-acquiring page table 2697 * race occurs while re-acquiring page table
@@ -2734,7 +2735,7 @@ retry_avoidcopy:
2734 */ 2735 */
2735 spin_lock(ptl); 2736 spin_lock(ptl);
2736 ptep = huge_pte_offset(mm, address & huge_page_mask(h)); 2737 ptep = huge_pte_offset(mm, address & huge_page_mask(h));
2737 if (likely(pte_same(huge_ptep_get(ptep), pte))) { 2738 if (likely(ptep && pte_same(huge_ptep_get(ptep), pte))) {
2738 ClearPagePrivate(new_page); 2739 ClearPagePrivate(new_page);
2739 2740
2740 /* Break COW */ 2741 /* Break COW */