diff --git a/include/linux/mm.h b/include/linux/mm.h index 418d26608ece..c0556665496e 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2872,7 +2872,7 @@ static inline void ptlock_free(struct ptdesc *ptdesc) static inline spinlock_t *ptlock_ptr(struct ptdesc *ptdesc) { - return &ptdesc->ptl; + return (ptdesc) ? &ptdesc->ptl : NULL; } #endif /* ALLOC_SPLIT_PTLOCKS */ diff --git a/mm/pgtable-generic.c b/mm/pgtable-generic.c index 4fcd959dcc4d..7796339d7ef2 100644 --- a/mm/pgtable-generic.c +++ b/mm/pgtable-generic.c @@ -370,6 +370,8 @@ pte_t *__pte_offset_map_lock(struct mm_struct *mm, pmd_t *pmd, if (unlikely(!pte)) return pte; ptl = pte_lockptr(mm, &pmdval); + if (unlikely(!ptl)) + return NULL; spin_lock(ptl); if (likely(pmd_same(pmdval, pmdp_get_lockless(pmd)))) { *ptlp = ptl;