]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm/mmap: Fix mmap_region() maple tree store.
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Wed, 17 Feb 2021 22:03:35 +0000 (17:03 -0500)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Wed, 17 Feb 2021 22:03:35 +0000 (17:03 -0500)
mas_set_range() before vma_mas_link() as the address may have changed
as commented above in the code.

Do the same in the error path.

This forces a reset of the mas->node to MA_START.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
mm/mmap.c

index 24adca4cffe84772ba74bea168fe1150b5267c78..cf6ee2f9ea74f2db42a8d1869c809f43599008b0 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2616,7 +2616,6 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
                goto expanded;
        }
 
-       mas_set_range(&mas, addr, end - 1);
 cannot_expand:
        /*
         * Determine the object being mapped and call the appropriate
@@ -2712,11 +2711,8 @@ cannot_expand:
                        goto free_vma;
        }
 
-       // Very likely a shorter walk.
-       mas = ma_prev;
-       mas.last = end - 1;
-       mas.index = addr;
-       mas_walk(&mas);
+       // addr may have changed.
+       mas_set_range(&mas, addr, end - 1);
        vma_mas_link(mm, vma, &mas);
 
        /* Once vma denies write, undo our temporary denial count */
@@ -2763,6 +2759,7 @@ unmap_and_free_vma:
        vma->vm_file = NULL;
 
        /* Undo any partial mapping done by a device driver. */
+       mas_set_range(&mas, addr, end - 1);
        unmap_region(mm, vma, &mas, vma->vm_start, vma->vm_end, prev, max);
        charged = 0;
        if (vm_flags & VM_SHARED)