]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm: Avoid rewalk in mmap_region v6.1_backport
authorLiam R. Howlett <Liam.Howlett@oracle.com>
Fri, 21 Apr 2023 15:08:22 +0000 (11:08 -0400)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Mon, 24 Apr 2023 19:44:55 +0000 (15:44 -0400)
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
mm/mmap.c

index 391ade554742e478dc2d4ed2ae6ebb9d59eb4d83..1d1ba0fa263f35898da60a059346c38c6b84b2f1 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2596,9 +2596,13 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
                goto expanded;
        }
 
+cannot_expand:
+       if (prev)
+               mas_next_range(&mas, ULONG_MAX);
+       BUG_ON(mas.last < addr);
+       BUG_ON(mas.index > end - 1);
        mas.index = addr;
        mas.last = end - 1;
-cannot_expand:
        /*
         * Determine the object being mapped and call the appropriate
         * specific mapper. the address has already been validated, but
@@ -2695,7 +2699,7 @@ cannot_expand:
        if (vma->vm_file)
                i_mmap_lock_write(vma->vm_file->f_mapping);
 
-       vma_mas_store(vma, &mas);
+       mas_store_prealloc(&mas, vma);
        mm->map_count++;
        if (vma->vm_file) {
                if (vma->vm_flags & VM_SHARED)