Skip to content

Commit

Permalink
hugetlb: release pages in the error path of hugetlb_cow()
Browse files Browse the repository at this point in the history
If we fail to prepare an anon_vma, the {new, old}_page should be released,
or they will leak.

Signed-off-by: Hillf Danton <[email protected]>
Reviewed-by: Andrea Arcangeli <[email protected]>
Cc: Hugh Dickins <[email protected]>
Cc: Johannes Weiner <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Hillf Danton authored and torvalds committed Nov 16, 2011
1 parent 66e13e6 commit ea4039a
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mm/hugetlb.c
Original file line number Diff line number Diff line change
Expand Up @@ -2422,6 +2422,8 @@ static int hugetlb_cow(struct mm_struct *mm, struct vm_area_struct *vma,
* anon_vma prepared.
*/
if (unlikely(anon_vma_prepare(vma))) {
page_cache_release(new_page);
page_cache_release(old_page);
/* Caller expects lock to be held */
spin_lock(&mm->page_table_lock);
return VM_FAULT_OOM;
Expand Down

0 comments on commit ea4039a

Please sign in to comment.