aboutsummaryrefslogtreecommitdiffstats
path: root/mm/mmap.c
diff options
context:
space:
mode:
authorGonzalo Matias Juarez Tello <gmjuareztello@gmail.com>2021-06-28 19:38:39 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2021-06-29 10:53:50 -0700
commit78d9cf6041b968cc881fd22e25e2662d1cec4dba (patch)
tree537708f69ad1f4228d5f4c2ac6551acb5e485dd0 /mm/mmap.c
parentmm: ignore MAP_EXECUTABLE in ksys_mmap_pgoff() (diff)
downloadlinux-dev-78d9cf6041b968cc881fd22e25e2662d1cec4dba.tar.xz
linux-dev-78d9cf6041b968cc881fd22e25e2662d1cec4dba.zip
mm/mmap.c: logic of find_vma_intersection repeated in __do_munmap
Logic of find_vma_intersection() is repeated in __do_munmap(). Also, prev is assigned a value before checking vma->vm_start >= end which might end up on a return statement making that assignment useless. Calling find_vma_intersection() checks that condition and returns NULL if no vma is found, hence only the !vma check is needed in __do_munmap(). Link: https://lkml.kernel.org/r/20210409162129.18313-1-gmjuareztello@gmail.com Signed-off-by: Gonzalo Matias Juarez Tello <gmjuareztello@gmail.com> Reviewed-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: David Hildenbrand <david@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to '')
-rw-r--r--mm/mmap.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/mm/mmap.c b/mm/mmap.c
index f9a61f7dc540..bb128a42557e 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2828,16 +2828,11 @@ int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len,
*/
arch_unmap(mm, start, end);
- /* Find the first overlapping VMA */
- vma = find_vma(mm, start);
+ /* Find the first overlapping VMA where start < vma->vm_end */
+ vma = find_vma_intersection(mm, start, end);
if (!vma)
return 0;
prev = vma->vm_prev;
- /* we have start < vma->vm_end */
-
- /* if it doesn't overlap, we have nothing.. */
- if (vma->vm_start >= end)
- return 0;
/*
* If we need to split any vma, do it now to save pain later.