Skip to content

Commit ad6e519

Browse files
Hugh DickinsLinus Torvalds
authored andcommitted
[PATCH] mm: follow_page invalid pte_page
The follow_page write-access case is relying on pte_page before checking pfn_valid: rearrange that - and we don't need three struct page *pages. (I notice mempolicy.c's verify_pages is also relying on pte_page, but I'll leave that to Andi: maybe it ought to be failing on, or skipping over, VM_IO or VM_RESERVED vmas?) Signed-off-by: Hugh Dickins <hugh@veritas.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent e11f2cc commit ad6e519

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

mm/memory.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -637,15 +637,11 @@ follow_page(struct mm_struct *mm, unsigned long address, int write)
637637
if (pte_present(pte)) {
638638
if (write && !pte_write(pte))
639639
goto out;
640-
if (write && !pte_dirty(pte)) {
641-
struct page *page = pte_page(pte);
642-
if (!PageDirty(page))
643-
set_page_dirty(page);
644-
}
645640
pfn = pte_pfn(pte);
646641
if (pfn_valid(pfn)) {
647-
struct page *page = pfn_to_page(pfn);
648-
642+
page = pfn_to_page(pfn);
643+
if (write && !pte_dirty(pte) && !PageDirty(page))
644+
set_page_dirty(page);
649645
mark_page_accessed(page);
650646
return page;
651647
}

0 commit comments

Comments
 (0)