diff mbox series

remap_file_pages: Use vma_lookup() instead of find_vma()

Message ID 20210817135234.1550204-1-Liam.Howlett@oracle.com (mailing list archive)
State New
Headers show
Series remap_file_pages: Use vma_lookup() instead of find_vma() | expand

Commit Message

Liam R. Howlett Aug. 17, 2021, 1:52 p.m. UTC
From: "Liam R. Howlett" <Liam.Howlett@Oracle.com>

Using vma_lookup() verifies the start address is contained in the found vma.
This results in easier to read code.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
---
 mm/mmap.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

David Hildenbrand Aug. 17, 2021, 2:03 p.m. UTC | #1
On 17.08.21 15:52, Liam Howlett wrote:
> From: "Liam R. Howlett" <Liam.Howlett@Oracle.com>
> 
> Using vma_lookup() verifies the start address is contained in the found vma.
> This results in easier to read code.
> 
> Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
> ---
>   mm/mmap.c | 5 +----
>   1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/mm/mmap.c b/mm/mmap.c
> index d9aa54be6244..1a23d4575cc4 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -2994,14 +2994,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
>   	if (mmap_write_lock_killable(mm))
>   		return -EINTR;
>   
> -	vma = find_vma(mm, start);
> +	vma = vma_lookup(mm, start);
>   
>   	if (!vma || !(vma->vm_flags & VM_SHARED))
>   		goto out;
>   
> -	if (start < vma->vm_start)
> -		goto out;
> -
>   	if (start + size > vma->vm_end) {
>   		struct vm_area_struct *next;
>   
> 

Reviewed-by: David Hildenbrand <david@redhat.com>
diff mbox series

Patch

diff --git a/mm/mmap.c b/mm/mmap.c
index d9aa54be6244..1a23d4575cc4 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2994,14 +2994,11 @@  SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
 	if (mmap_write_lock_killable(mm))
 		return -EINTR;
 
-	vma = find_vma(mm, start);
+	vma = vma_lookup(mm, start);
 
 	if (!vma || !(vma->vm_flags & VM_SHARED))
 		goto out;
 
-	if (start < vma->vm_start)
-		goto out;
-
 	if (start + size > vma->vm_end) {
 		struct vm_area_struct *next;