Skip to content

Commit 4482824

Browse files
Hugh Dickinstorvalds
authored andcommitted
mm: page_vma_mapped_walk(): crossing page table boundary
page_vma_mapped_walk() cleanup: adjust the test for crossing page table boundary - I believe pvmw->address is always page-aligned, but nothing else here assumed that; and remember to reset pvmw->pte to NULL after unmapping the page table, though I never saw any bug from that. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Hugh Dickins <[email protected]> Acked-by: Kirill A. Shutemov <[email protected]> Cc: Alistair Popple <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: Peter Xu <[email protected]> Cc: Ralph Campbell <[email protected]> Cc: Wang Yugui <[email protected]> Cc: Will Deacon <[email protected]> Cc: Yang Shi <[email protected]> Cc: Zi Yan <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent e2e1d40 commit 4482824

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

mm/page_vma_mapped.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,16 +244,16 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)
244244
if (pvmw->address >= end)
245245
return not_found(pvmw);
246246
/* Did we cross page table boundary? */
247-
if (pvmw->address % PMD_SIZE == 0) {
248-
pte_unmap(pvmw->pte);
247+
if ((pvmw->address & (PMD_SIZE - PAGE_SIZE)) == 0) {
249248
if (pvmw->ptl) {
250249
spin_unlock(pvmw->ptl);
251250
pvmw->ptl = NULL;
252251
}
252+
pte_unmap(pvmw->pte);
253+
pvmw->pte = NULL;
253254
goto restart;
254-
} else {
255-
pvmw->pte++;
256255
}
256+
pvmw->pte++;
257257
} while (pte_none(*pvmw->pte));
258258

259259
if (!pvmw->ptl) {

0 commit comments

Comments
 (0)