From: Vlastimil Babka Date: Thu, 9 Mar 2023 11:12:53 +0000 (+0100) Subject: mm/mmap/vma_merge: initialize mid and next in natural order X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=5cd70b96debbce9182e903cc6f4ed261ae55fa8b;p=linux.git mm/mmap/vma_merge: initialize mid and next in natural order It is more intuitive to go from prev to mid and then next. No functional change. Link: https://lkml.kernel.org/r/20230309111258.24079-6-vbabka@suse.cz Signed-off-by: Vlastimil Babka Reviewed-by: Lorenzo Stoakes Reviewed-by: Liam R. Howlett Cc: Matthew Wilcox (Oracle) Cc: Suren Baghdasaryan Signed-off-by: Andrew Morton --- diff --git a/mm/mmap.c b/mm/mmap.c index 8394901c35b43..d3765dcd9a155 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -912,10 +912,11 @@ struct vm_area_struct *vma_merge(struct vma_iterator *vmi, struct mm_struct *mm, if (vm_flags & VM_SPECIAL) return NULL; - next = find_vma(mm, prev ? prev->vm_end : 0); - mid = next; - if (next && next->vm_end == end) /* cases 6, 7, 8 */ - next = find_vma(mm, next->vm_end); + mid = find_vma(mm, prev ? prev->vm_end : 0); + if (mid && mid->vm_end == end) /* cases 6, 7, 8 */ + next = find_vma(mm, mid->vm_end); + else + next = mid; /* verify some invariant that must be enforced by the caller */ VM_WARN_ON(prev && addr <= prev->vm_start);