xtensa: fix lock_mm_and_find_vma in case VMA not found
[linux-2.6-block.git] / mm / nommu.c
index fdc392735ec6d982639d6f6c293ef2c72402c047..c072a660ec2cfb522903828038a9fce9be19c4c1 100644 (file)
@@ -637,8 +637,13 @@ EXPORT_SYMBOL(find_vma);
 struct vm_area_struct *lock_mm_and_find_vma(struct mm_struct *mm,
                        unsigned long addr, struct pt_regs *regs)
 {
+       struct vm_area_struct *vma;
+
        mmap_read_lock(mm);
-       return vma_lookup(mm, addr);
+       vma = vma_lookup(mm, addr);
+       if (!vma)
+               mmap_read_unlock(mm);
+       return vma;
 }
 
 /*