From f69950789983fe9916a58cb6a6bf7c77832c1087 Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Wed, 16 Nov 2022 12:29:34 -0500 Subject: [PATCH] vma_merge: Set vma iterator to correct position. When merging the previous value, set the vma iterator to the previous slot. Don't use the vma iterator to get the next/prev so that it is in the correct position for a write. Signed-off-by: Liam R. Howlett --- mm/mmap.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 3c52c5201b19..066c1416efc4 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -994,6 +994,7 @@ struct vm_area_struct *vma_merge(struct vma_iterator *vmi, struct mm_struct *mm, && can_vma_merge_after(prev, vm_flags, anon_vma, file, pgoff, vm_userfaultfd_ctx, anon_name)) { merge_prev = true; + vma_prev(vmi); } } /* Can we merge the successor? */ @@ -1085,9 +1086,6 @@ struct vm_area_struct *vma_merge(struct vma_iterator *vmi, struct mm_struct *mm, validate_mm(mm); khugepaged_enter_vma(res, vm_flags); - if (res) - vma_iter_set(vmi, end); - return res; } -- 2.49.0