downgrade = false;
else if (prev && (prev->vm_flags & VM_GROWSUP))
downgrade = false;
- else {
- mas_unlock(mas);
+ else
mmap_write_downgrade(mm);
- }
}
+ /* Have to unlock since unmap_vmas may sleep */
+ mas_unlock(mas);
unmap_region(mm, &mt_detach, vma, prev, next, start, end);
+
/* Statistics and freeing VMAs */
+ /* Have to remain unlocked as remove_vma() might sleep */
remove_mt(mm, &mt_detach);
- mtree_destroy(&mt_detach);
+ /* validate_mt() requires unlocking due to anon_vma check if DEBUG_RB*/
validate_mm(mm);
+ if (!downgrade)
+ mas_lock(mas);
+ mtree_destroy(&mt_detach);
return downgrade ? 1 : 0;
}