]> git.hungrycats.org Git - linux/commitdiff
[PATCH] mm: follow_page invalid pte_page
authorHugh Dickins <hugh@veritas.com>
Sat, 5 Jun 2004 03:52:06 +0000 (20:52 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Sat, 5 Jun 2004 03:52:06 +0000 (20:52 -0700)
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>
mm/memory.c

index 578070758905275564ad2233b594244fe90d2a75..3df1f05e76b8e945ecf95b829b1c82185aabfcbf 100644 (file)
@@ -637,15 +637,11 @@ follow_page(struct mm_struct *mm, unsigned long address, int write)
        if (pte_present(pte)) {
                if (write && !pte_write(pte))
                        goto out;
-               if (write && !pte_dirty(pte)) {
-                       struct page *page = pte_page(pte);
-                       if (!PageDirty(page))
-                               set_page_dirty(page);
-               }
                pfn = pte_pfn(pte);
                if (pfn_valid(pfn)) {
-                       struct page *page = pfn_to_page(pfn);
-                       
+                       page = pfn_to_page(pfn);
+                       if (write && !pte_dirty(pte) && !PageDirty(page))
+                               set_page_dirty(page);
                        mark_page_accessed(page);
                        return page;
                }