提交 46e6b31d 编写于 作者: L Liam Howlett 提交者: Linus Torvalds

lib/test_hmm: use vma_lookup() in dmirror_migrate()

Use vma_lookup() to find the VMA at a specific address.  As vma_lookup()
will return NULL if the address is not within any VMA, the start address
no longer needs to be validated.

Link: https://lkml.kernel.org/r/20210521174745.2219620-18-Liam.Howlett@Oracle.comSigned-off-by: NLiam R. Howlett <Liam.Howlett@Oracle.com>
Reviewed-by: NLaurent Dufour <ldufour@linux.ibm.com>
Acked-by: NDavid Hildenbrand <david@redhat.com>
Acked-by: NDavidlohr Bueso <dbueso@suse.de>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 9016dded
...@@ -686,9 +686,8 @@ static int dmirror_migrate(struct dmirror *dmirror, ...@@ -686,9 +686,8 @@ static int dmirror_migrate(struct dmirror *dmirror,
mmap_read_lock(mm); mmap_read_lock(mm);
for (addr = start; addr < end; addr = next) { for (addr = start; addr < end; addr = next) {
vma = find_vma(mm, addr); vma = vma_lookup(mm, addr);
if (!vma || addr < vma->vm_start || if (!vma || !(vma->vm_flags & VM_READ)) {
!(vma->vm_flags & VM_READ)) {
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册