]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mmap: Don't reset mas until needed in mmap_region()
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Tue, 24 Nov 2020 21:24:24 +0000 (16:24 -0500)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Tue, 5 Jan 2021 17:33:27 +0000 (12:33 -0500)
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
mm/mmap.c

index 07c8803bc5a5fd677e9e3d15e58fdf1521c941bf..5ede23b56f0abf661862f782ba72f567393f2cee 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2649,9 +2649,6 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
                goto expanded;
        }
 
-       mas_reset(&mas);
-       mas_set(&mas, addr);
-       mas.last = end - 1;
 cannot_expand:
        /*
         * Determine the object being mapped and call the appropriate
@@ -2747,6 +2744,13 @@ cannot_expand:
                        goto free_vma;
        }
 
+       /*
+        * mas was called for the prev vma, and that may not be the correct
+        * location for the vma being inserted.
+        */
+       if (mas.max < addr)
+               mas_reset(&mas);
+       mas_set(&mas, addr);
        mas_walk(&mas);
        vma_mas_link(mm, vma, &mas, prev);
        /* Once vma denies write, undo our temporary denial count */