Commit 0e6799db authored by Miaohe Lin's avatar Miaohe Lin Committed by Linus Torvalds
Browse files

mm/mremap:: 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 code.

Link: https://lkml.kernel.org/r/20220312083118.48284-1-linmiaohe@huawei.com


Signed-off-by: default avatarMiaohe Lin <linmiaohe@huawei.com>
Reviewed-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 360cd061
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -942,8 +942,8 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,

	if (mmap_write_lock_killable(current->mm))
		return -EINTR;
	vma = find_vma(mm, addr);
	if (!vma || vma->vm_start > addr) {
	vma = vma_lookup(mm, addr);
	if (!vma) {
		ret = EFAULT;
		goto out;
	}