Skip to content

Commit 92d5df3

Browse files
ZhangPengakpm00
authored andcommitted
mm/madvise: use vma_lookup() instead of find_vma()
Using vma_lookup() verifies the address is contained in the found vma. This results in easier to read the code. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: ZhangPeng <[email protected]> Reviewed-by: Liam R. Howlett <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 6b0ba2a commit 92d5df3

File tree

1 file changed

+1
-13
lines changed

1 file changed

+1
-13
lines changed

mm/madvise.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -852,21 +852,9 @@ static long madvise_dontneed_free(struct vm_area_struct *vma,
852852
*prev = NULL; /* mmap_lock has been dropped, prev is stale */
853853

854854
mmap_read_lock(mm);
855-
vma = find_vma(mm, start);
855+
vma = vma_lookup(mm, start);
856856
if (!vma)
857857
return -ENOMEM;
858-
if (start < vma->vm_start) {
859-
/*
860-
* This "vma" under revalidation is the one
861-
* with the lowest vma->vm_start where start
862-
* is also < vma->vm_end. If start <
863-
* vma->vm_start it means an hole materialized
864-
* in the user address space within the
865-
* virtual range passed to MADV_DONTNEED
866-
* or MADV_FREE.
867-
*/
868-
return -ENOMEM;
869-
}
870858
/*
871859
* Potential end adjustment for hugetlb vma is OK as
872860
* the check below keeps end within vma.

0 commit comments

Comments
 (0)