mm/madvise: use vma_lookup() instead of find_vma()
authorMiaohe Lin <linmiaohe@huawei.com>
Tue, 22 Mar 2022 21:46:41 +0000 (14:46 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 22 Mar 2022 22:57:09 +0000 (15:57 -0700)
Using vma_lookup() verifies the start address is contained in the found
vma.  This results in easier to read the code.

Link: https://lkml.kernel.org/r/20220311082731.63513-1-linmiaohe@huawei.com
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/madvise.c

index 7b5d6fc..2efcde2 100644 (file)
@@ -849,8 +849,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;
                }