]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm/mmap: Find next vma in do_brk_munmap() prior to updating tree.
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Tue, 9 Feb 2021 00:33:02 +0000 (19:33 -0500)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Tue, 9 Feb 2021 00:33:02 +0000 (19:33 -0500)
The tree update may invalidate the location and cause a longer search if the VMA does not
preceed a NULL entry

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

index b4879e66f87de55b70265fc56df6127adbf2a313..a630696a19fbdae49c88c8f65a9ec5ec9b4d4500 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2948,6 +2948,8 @@ static int do_brk_munmap(struct ma_state *mas, struct vm_area_struct *vma,
                return ret;
 
        ret = 1;
+       ma_next = *mas;
+       next = mas_next(&ma_next, -1);
        // Change the oldbrk of vma to the newbrk of the munmap area
        vma_adjust_trans_huge(vma, vma->vm_start, newbrk, 0);
        if (vma->anon_vma) {
@@ -2972,8 +2974,6 @@ static int do_brk_munmap(struct ma_state *mas, struct vm_area_struct *vma,
        }
 
        mmap_write_downgrade(mm);
-       ma_next = *mas;
-       next = mas_next(&ma_next, -1);
        unmap_region(mm, &unmap, mas, newbrk, oldbrk, vma,
                     next ? next->vm_start : 0);
        /* Statistics */