Commit 485583e1 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] Fix bogus get_page() calls in hugepage code

From: David Gibson <david@gibson.dropbear.id.au>

Some versions of follow_huge_addr() and follow_huge_pmd() are doing a
get_page() on the target page.  They shouldn't: follow_page() returns an
unpinned page and it is the caller's responsibility to pin the page (if
desired) before dropping page_table_lock.
parent 9c59105e
...@@ -206,10 +206,8 @@ follow_huge_pmd(struct mm_struct *mm, unsigned long address, ...@@ -206,10 +206,8 @@ follow_huge_pmd(struct mm_struct *mm, unsigned long address,
struct page *page; struct page *page;
page = pte_page(*(pte_t *)pmd); page = pte_page(*(pte_t *)pmd);
if (page) { if (page)
page += ((address & ~HPAGE_MASK) >> PAGE_SHIFT); page += ((address & ~HPAGE_MASK) >> PAGE_SHIFT);
get_page(page);
}
return page; return page;
} }
#endif #endif
......
...@@ -170,7 +170,6 @@ struct page *follow_huge_addr(struct mm_struct *mm, struct vm_area_struct *vma, ...@@ -170,7 +170,6 @@ struct page *follow_huge_addr(struct mm_struct *mm, struct vm_area_struct *vma,
ptep = huge_pte_offset(mm, addr); ptep = huge_pte_offset(mm, addr);
page = pte_page(*ptep); page = pte_page(*ptep);
page += ((addr & ~HPAGE_MASK) >> PAGE_SHIFT); page += ((addr & ~HPAGE_MASK) >> PAGE_SHIFT);
get_page(page);
return page; return page;
} }
int pmd_huge(pmd_t pmd) int pmd_huge(pmd_t pmd)
......
...@@ -360,10 +360,8 @@ follow_huge_pmd(struct mm_struct *mm, unsigned long address, ...@@ -360,10 +360,8 @@ follow_huge_pmd(struct mm_struct *mm, unsigned long address,
BUG_ON(! pmd_hugepage(*pmd)); BUG_ON(! pmd_hugepage(*pmd));
page = hugepte_page(*(hugepte_t *)pmd); page = hugepte_page(*(hugepte_t *)pmd);
if (page) { if (page)
page += ((address & ~HPAGE_MASK) >> PAGE_SHIFT); page += ((address & ~HPAGE_MASK) >> PAGE_SHIFT);
get_page(page);
}
return page; return page;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment