if (!vma_is_anonymous(vma))
goto inval;
+ /* find_mergeable_anon_vma uses adjacent vmas which are not locked */
+ if (!vma->anon_vma)
+ goto inval;
+
/*
* Due to the possibility of userfault handler dropping mmap_lock, avoid
* it for now and fall back to page fault handling under mmap_lock.
struct anon_vma *anon_vma = NULL;
struct vm_area_struct *prev, *next;
- /*
- * This search can be done with per-vma lock and without mmap_lock,
- * therefore acquire RCU read lock to prevent the tree from changing.
- */
- rcu_read_lock();
-
/* Try next first. */
next = mas_walk(&mas);
if (next) {
anon_vma = reusable_anon_vma(next, vma, next);
- if (anon_vma) {
- rcu_read_unlock();
+ if (anon_vma)
return anon_vma;
- }
}
prev = mas_prev(&mas, 0);
if (prev)
anon_vma = reusable_anon_vma(prev, prev, vma);
- rcu_read_unlock();
/*
* We might reach here with anon_vma == NULL if we can't find
* any reusable anon_vma.