From: Liam R. Howlett <Liam.Howlett@Oracle.com> Date: Tue, 9 Feb 2021 00:33:02 +0000 (-0500) Subject: mm/mmap: Find next vma in do_brk_munmap() prior to updating tree. X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=cf8dcab1959006af3a55d708c2c85609e284ec14;p=users%2Fjedix%2Flinux-maple.git mm/mmap: Find next vma in do_brk_munmap() prior to updating tree. 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> --- diff --git a/mm/mmap.c b/mm/mmap.c index b4879e66f87d..a630696a19fb 100644 --- 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 */