Skip to contentSkip to conversation

mm/madvise: Use vma_lookup() instead of find_vma()

PATCH Applied Miaohe Lin 2 participants 2 messages Mar 11, 2022

Subsystems (2)
lore
Share & tools
lore

Miaohe Lin

author
#0 lore raw

PATCH 1/1 mm/madvise: Use vma_lookup() instead of find_vma()

Using vma_lookup() verifies the start address is contained in the found vma. This results in easier to read the code.

---
 mm/madvise.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mm/madvise.c +2 -2
index 5b6d796e55de..afd68bfc77d4 100644
@@ -883,8 +883,8 @@ static long madvise_populate(struct vm_area_struct *vma,
 		 * our VMA might have been split.
 		 */
 		if (!vma || start >= vma->vm_end) {
-			vma = find_vma(mm, start);
-			if (!vma || start < vma->vm_start)
+			vma = vma_lookup(mm, start);
+			if (!vma)
 				return -ENOMEM;
 		}
 
Signature · 1 line
2.23.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · Miaohe Lin

Using vma_lookup() verifies the start address is contained in the found vma. This results in easier to read the code.

---
 mm/madvise.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mm/madvise.c +0 -0
index 5b6d796e55de..afd68bfc77d4 100644

mm/madvise.c static long madvise_populate(struct vm_area_struct *vma, · line 890

Quoted 10 lines
mm/madvise.c +2 -2
@@ -883,8 +883,8 @@ static long madvise_populate(struct vm_area_struct *vma,
 		 * our VMA might have been split.
 		 */
 		if (!vma || start >= vma->vm_end) {
-			vma = find_vma(mm, start);
-			if (!vma || start < vma->vm_start)
+			vma = vma_lookup(mm, start);
+			if (!vma)
 				return -ENOMEM;
 		}
 
Signature · 3 lines
Thanks,

David / dhildenb