hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/IDAIXT ------------------------------------------------- When find_vma() fails to find a VMA , the function returns without releasing the mmap read lock acquired earlier. This causes a lock imbalance and may lead to deadlocks or other synchronization issues. The issue was introduced by the recent optimization commit 43ac0d3f00c6 ("mempolicy: mmap_lock is not needed while migrating folios"). While removing unnecessary mmap_lock calls, the error path handling for find_vma() failure was overlooked. Add the missing mmap_read_unlock() call in the error path to properly release the lock before returning. Fixes: 43ac0d3f00c6 ("mempolicy: mmap_lock is not needed while migrating folios") Signed-off-by: Ze Zuo <zuoze1@huawei.com> --- mm/mempolicy.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index b960310a70f9..324e354ac077 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -1107,8 +1107,10 @@ static long migrate_to_node(struct mm_struct *mm, int source, int dest, mmap_read_lock(mm); vma = find_vma(mm, 0); - if (unlikely(!vma)) + if (unlikely(!vma)) { + mmap_read_unlock(mm); return 0; + } /* * This does not migrate the range, but isolates all pages that -- 2.25.1