Skip to content

Commit

Permalink
mm/mremap:: use vma_lookup() instead of find_vma()
Browse files Browse the repository at this point in the history
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: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
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>
  • Loading branch information
Miaohe Lin authored and Linus Torvalds committed Mar 22, 2022
1 parent 360cd06 commit 0e6799d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mm/mremap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 0e6799d

Please sign in to comment.