Commit ea4039a3 authored by Hillf Danton's avatar Hillf Danton Committed by Linus Torvalds

hugetlb: release pages in the error path of hugetlb_cow()

If we fail to prepare an anon_vma, the {new, old}_page should be released,
or they will leak.
Signed-off-by: default avatarHillf Danton <dhillf@gmail.com>
Reviewed-by: default avatarAndrea Arcangeli <aarcange@redhat.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Johannes Weiner <jweiner@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 66e13e66
......@@ -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;
......
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