diff --git a/mm/mmap.c b/mm/mmap.c index bfe139bf94af..bd2140cfcf36 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -531,6 +531,7 @@ inline int vma_expand(struct ma_state *mas, struct vm_area_struct *vma, struct file *file = vma->vm_file; bool remove_next = false; + vma_start_write(vma); if (next && (vma != next) && (end == next->vm_end)) { remove_next = true; /* Lock the VMA before removing it */ @@ -539,7 +540,6 @@ inline int vma_expand(struct ma_state *mas, struct vm_area_struct *vma, int error; anon_vma = next->anon_vma; - vma_start_write(vma); vma->anon_vma = anon_vma; error = anon_vma_clone(vma, next); if (error) @@ -556,7 +556,6 @@ inline int vma_expand(struct ma_state *mas, struct vm_area_struct *vma, if (mas_preallocate(mas, vma, GFP_KERNEL)) goto nomem; - vma_start_write(vma); vma_adjust_trans_huge(vma, start, end, 0); if (file) { @@ -2433,6 +2432,9 @@ int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma, if (new->vm_ops && new->vm_ops->open) new->vm_ops->open(new); + vma_start_write(vma); + vma_start_write(new); + if (new_below) err = vma_adjust(vma, addr, vma->vm_end, vma->vm_pgoff + ((addr - new->vm_start) >> PAGE_SHIFT), new);