Re: [PATCH] mm/migrate_device: fix pgtable leak in migrate_vma_insert_huge_pmd_page
From: Sunny Patel
Date: Mon Apr 27 2026 - 02:49:05 EST
On Sat, 25 Apr 2026 10:21:01 -0400, Zi Yan wrote:
> I think the "goto abort" above pmd_lock() need to do pte_free():
>
> if (folio_is_device_private(folio)) {
> ...
> } else {
> if (folio_is_zone_device(folio) &&
> !folio_is_device_coherent(folio)) {
> goto abort; <-- this one
> }
> ...
> }
>
> The lock is not taken yet, so you might need to add a pte_free()
> before goto abort.
You are right. The pgtable is allocated before this check and
the lock has not been taken yet at this point, so goto
unlock_abort would be incorrect here. A pte_free() call is
needed before this goto abort.
Sent v2 with the changes.
https://lore.kernel.org/linux-mm/20260427063729.17294-1-nueralspacetech@xxxxxxxxx/
Thanks for catching this.
Regards,
Sunny Patel