mm/migrate_device: fix spinlock leak in migrate_vma_insert_huge_pmd_page
Subsystems (2)
PATCH 1/1 mm/migrate_device: fix spinlock leak in migrate_vma_insert_huge_pmd_page
When check_stable_address_space() fails after the PMD spinlock has been acquired via pmd_lock(), the code jumps directly to the abort label, bypassing the spin_unlock() call in unlock_abort. This causes the PMD spinlock to be permanently held, leading to a deadlock.
Change the goto target from abort to unlock_abort to ensure the spinlock is always released on this error path.
--- mm/migrate_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/migrate_device.c +1 -1
@@ -850,7 +850,7 @@ static int migrate_vma_insert_huge_pmd_page(struct migrate_vma *migrate, ptl =pmd_lock (vma->vm_mm, pmdp); csa_ret =check_stable_address_space (vma->vm_mm);if (csa_ret) - goto abort; + goto unlock_abort;/* * Check for userfaultfd but do not deliver the fault. Instead,
Signature · 1 line
2.43.0
Andrew Morton
maintainerQuoted 13 lines · On Sat, 25 Apr 2026 19:05:27 +0530 Sunny Patel <[email protected]>…
When
check_stable_address_space()fails after the PMD spinlock has been acquired viapmd_lock(), the code jumps directly to the abort label, bypassing thespin_unlock()call inunlock_abort. This causes the PMD spinlock to be permanently held, leading to a deadlock.Change the goto target from abort to
unlock_abortto ensure the spinlock is always released on this error path....
mm/migrate_device.c static int migrate_vma_insert_huge_pmd_page(struct migrate_vma *migrate, · line 856
Quoted 8 lines
mm/migrate_device.c +1
-1@@ -850,7 +850,7 @@ static int migrate_vma_insert_huge_pmd_page(struct migrate_vma *migrate, ptl =pmd_lock (vma->vm_mm, pmdp); csa_ret =check_stable_address_space (vma->vm_mm);if (csa_ret) - goto abort; + goto unlock_abort;/* * Check for userfaultfd but do not deliver the fault. Instead,
whoops.
Balbir Singh
Acked-byQuoted 21 lines · Andrew Morton
Quoted 19 lines · On Sat, 25 Apr 2026 19:05:27 +0530 Sunny Patel <[email protected]>…
When
check_stable_address_space()fails after the PMD spinlock has been acquired viapmd_lock(), the code jumps directly to the abort label, bypassing thespin_unlock()call inunlock_abort. This causes the PMD spinlock to be permanently held, leading to a deadlock.Change the goto target from abort to
unlock_abortto ensure the spinlock is always released on this error path....
mm/migrate_device.c +1
-1@@ -850,7 +850,7 @@ static int migrate_vma_insert_huge_pmd_page(struct migrate_vma *migrate, ptl =pmd_lock (vma->vm_mm, pmdp); csa_ret =check_stable_address_space (vma->vm_mm);if (csa_ret) - goto abort; + goto unlock_abort;
Quoted 7 lines
mm/migrate_device.c static int migrate_vma_insert_huge_pmd_page(struct migrate_vma *migrate, · line 856
Quoted 2 lines
mm/migrate_device.c +0
-0/* * Check for userfaultfd but do not deliver the fault. Instead, whoops.
Fixes a30b48bf1b24 ("mm/migrate_device: implement THP migration of zone device pages")Cc <[email protected]>
Thanks
Quoted 5 lines · Sunny Patel
When
check_stable_address_space()fails after the PMD spinlock has been acquired viapmd_lock(), the code jumps directly to the abort label, bypassing thespin_unlock()call inunlock_abort. This causes the PMD spinlock to be permanently held, leading to a deadlock.
Quoted 8 lines
Change the goto target from abort to
unlock_abortto ensure the spinlock is always released on this error path.Signed-off-by Sunny Patel <[email protected]>--- mm/migrate_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
LGTM.
--
Best Regards,
Yan, Zi
Quoted 10 lines · Sunny Patel
When
check_stable_address_space()fails after the PMD spinlock has been acquired viapmd_lock(), the code jumps directly to the abort label, bypassing thespin_unlock()call inunlock_abort. This causes the PMD spinlock to be permanently held, leading to a deadlock.Change the goto target from abort to
unlock_abortto ensure the spinlock is always released on this error path.Signed-off-by Sunny Patel <[email protected]>---
Thanks!
Signature · 3 lines
Cheers, David