From cf8dcab1959006af3a55d708c2c85609e284ec14 Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Mon, 8 Feb 2021 19:33:02 -0500 Subject: [PATCH] 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 --- mm/mmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 */ -- 2.50.1