diff options
author | ZhangPeng | 2023-04-04 17:45:15 +0800 |
---|---|---|
committer | Andrew Morton | 2023-04-18 16:29:52 -0700 |
commit | 92d5df38ca91f138d4964d71a6835add95f99e59 (patch) | |
tree | 5403576ffdab2b81fb5cffa026969abac8ac6b99 | |
parent | 6b0ba2abbeede5e1756d54277e811cf2783eb0a8 (diff) |
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>
-rw-r--r-- | mm/madvise.c | 14 |
1 files changed, 1 insertions, 13 deletions
diff --git a/mm/madvise.c b/mm/madvise.c index 340125d08c03..405a2c4a0a18 100644 --- a/mm/madvise.c +++ b/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 */ mmap_read_lock(mm); - vma = find_vma(mm, start); + vma = vma_lookup(mm, start); if (!vma) 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 * the check below keeps end within vma. |