diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c index 261fc929b08d6e05be4e0cf2c1e1e9d05dfae3f6..9c87b3090a1bab1ae13d48d78e3f2eef5c5ce579 100644 --- a/mm/page_vma_mapped.c +++ b/mm/page_vma_mapped.c @@ -244,16 +244,16 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw) if (pvmw->address >= end) return not_found(pvmw); /* Did we cross page table boundary? */ - if (pvmw->address % PMD_SIZE == 0) { - pte_unmap(pvmw->pte); + if ((pvmw->address & (PMD_SIZE - PAGE_SIZE)) == 0) { if (pvmw->ptl) { spin_unlock(pvmw->ptl); pvmw->ptl = NULL; } + pte_unmap(pvmw->pte); + pvmw->pte = NULL; goto restart; - } else { - pvmw->pte++; } + pvmw->pte++; } while (pte_none(*pvmw->pte)); if (!pvmw->ptl) {