From 686ea6e61da61e46ae7068f73167ca26e0c67efb Mon Sep 17 00:00:00 2001 From: ZhangPeng Date: Mon, 17 Apr 2023 08:39:19 +0800 Subject: [PATCH] userfaultfd: use helper function range_in_vma() We can use range_in_vma() to check if dst_start, dst_start + len are within the dst_vma range. Minor readability improvement. Link: https://lkml.kernel.org/r/20230417003919.930515-1-zhangpeng362@huawei.com Signed-off-by: ZhangPeng Reviewed-by: David Hildenbrand Cc: Kefeng Wang Cc: Mike Kravetz Cc: Nanyong Sun Signed-off-by: Andrew Morton --- mm/userfaultfd.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c index 11cfd82c..e97a0b4 100644 --- a/mm/userfaultfd.c +++ b/mm/userfaultfd.c @@ -31,11 +31,7 @@ struct vm_area_struct *find_dst_vma(struct mm_struct *dst_mm, struct vm_area_struct *dst_vma; dst_vma = find_vma(dst_mm, dst_start); - if (!dst_vma) - return NULL; - - if (dst_start < dst_vma->vm_start || - dst_start + len > dst_vma->vm_end) + if (!range_in_vma(dst_vma, dst_start, dst_start + len)) return NULL; /* -- 2.7.4