mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
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/20230404094515.1883552-1-zhangpeng362@huawei.com Signed-off-by: ZhangPeng <zhangpeng362@huawei.com> Reviewed-by: Liam R. Howlett <Liam.Howlett@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
6b0ba2abbe
commit
92d5df38ca
1 changed files with 1 additions and 13 deletions
14
mm/madvise.c
14
mm/madvise.c
|
@ -852,21 +852,9 @@ static long madvise_dontneed_free(struct vm_area_struct *vma,
|
||||||
*prev = NULL; /* mmap_lock has been dropped, prev is stale */
|
*prev = NULL; /* mmap_lock has been dropped, prev is stale */
|
||||||
|
|
||||||
mmap_read_lock(mm);
|
mmap_read_lock(mm);
|
||||||
vma = find_vma(mm, start);
|
vma = vma_lookup(mm, start);
|
||||||
if (!vma)
|
if (!vma)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
if (start < vma->vm_start) {
|
|
||||||
/*
|
|
||||||
* This "vma" under revalidation is the one
|
|
||||||
* with the lowest vma->vm_start where start
|
|
||||||
* is also < vma->vm_end. If start <
|
|
||||||
* vma->vm_start it means an hole materialized
|
|
||||||
* in the user address space within the
|
|
||||||
* virtual range passed to MADV_DONTNEED
|
|
||||||
* or MADV_FREE.
|
|
||||||
*/
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* Potential end adjustment for hugetlb vma is OK as
|
* Potential end adjustment for hugetlb vma is OK as
|
||||||
* the check below keeps end within vma.
|
* the check below keeps end within vma.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue