Skip to contentSkip to conversation

mm/mmap: Use find_vma_intersection() in do_mmap() for overlap

PATCH Applied Liam Howlett 1 participant 1 message May 11, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/mmap: Use find_vma_intersection() in do_mmap() for overlap

Using find_vma_intersection() avoids the need for a temporary variable and makes the code cleaner.

---
 mm/mmap.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
mm/mmap.c +1 -3
index 1bbb3225c958..016715924529 100644
@@ -1456,9 +1456,7 @@ unsigned long do_mmap(struct file *file, unsigned long addr,
 		return addr;
 
 	if (flags & MAP_FIXED_NOREPLACE) {
-		struct vm_area_struct *vma = find_vma(mm, addr);
-
-		if (vma && vma->vm_start < addr + len)
+		if (find_vma_intersection(mm, addr, addr + len))
 			return -EEXIST;
 	}
 
Signature · 1 line
2.30.2