From: Max Filippov Date: Sat, 1 Jul 2023 10:31:55 +0000 (-0700) Subject: xtensa: fix lock_mm_and_find_vma in case VMA not found X-Git-Tag: v6.3.12~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=af6410c8f7c41ce25c02dc190499f0944ec29499;p=thirdparty%2Fkernel%2Fstable.git xtensa: fix lock_mm_and_find_vma in case VMA not found commit 03f889378f33aa9a9d8e5f49ba94134cf6158090 upstream. MMU version of lock_mm_and_find_vma releases the mm lock before returning when VMA is not found. Do the same in noMMU version. This fixes hang on an attempt to handle protection fault. Fixes: d85a143b69ab ("xtensa: fix NOMMU build with lock_mm_and_find_vma() conversion") Signed-off-by: Max Filippov Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- diff --git a/mm/nommu.c b/mm/nommu.c index 07a3af6a94ea8..4e0c28644ffa0 100644 --- a/mm/nommu.c +++ b/mm/nommu.c @@ -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; } /*