Skip to content

Commit

Permalink
hugetlb: add missing unlock in avoidcopy path in hugetlb_cow()
Browse files Browse the repository at this point in the history
This patch fixes possible deadlock in hugepage lock_page()
by adding missing unlock_page().

libhugetlbfs test will hit this bug when the next patch in this
patchset ("hugetlb, HWPOISON: move PG_HWPoison bit check") is applied.

Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
Acked-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
  • Loading branch information
Naoya Horiguchi authored and Andi Kleen committed Aug 11, 2010
1 parent e3390f6 commit 28957a5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mm/hugetlb.c
Original file line number Diff line number Diff line change
Expand Up @@ -2324,9 +2324,11 @@ static int hugetlb_cow(struct mm_struct *mm, struct vm_area_struct *vma,
* and just make the page writable */
avoidcopy = (page_mapcount(old_page) == 1);
if (avoidcopy) {
if (!trylock_page(old_page))
if (!trylock_page(old_page)) {
if (PageAnon(old_page))
page_move_anon_rmap(old_page, vma, address);
} else
unlock_page(old_page);
set_huge_ptep_writable(vma, address, ptep);
return 0;
}
Expand Down

0 comments on commit 28957a5

Please sign in to comment.