Re: [PATCH v2] mm/migrate_device: Cleanup up PMD Checks and warnings
From: Sunny Patel
Date: Fri Apr 24 2026 - 13:36:26 EST
On Sun, 19 Apr 2026 23:17:43 +0530 Sunny Patel <nueralspacetech@xxxxxxxxx> wrote:
> Remove the odd VM_WARN_ON_FOLIO(!folio, folio) usage and replace it
> with a simpler VM_WARN_ON_ONCE(!folio) check.
>
> Drop the redundant VM_WARN_ON_ONCE(!pmd_none(*pmdp) &&
> !is_huge_zero_pmd(*pmdp)).
>
> Refactor the PMD checks, making the control flow
> clearer and avoiding duplicate condition checks.
AI review might have found a bug in the surrounding code:
https://sashiko.dev/#/patchset/20260419174747.10701-1-nueralspacetech@xxxxxxxxx
NOTE: Ignore the previous message was sent on different
Subject Header by mistake.
After looking into the AI comment found two potential leak.
1. The goto should be unlock_abort instead of abort to ensure
the spinlock is released.
2. The pgtable allocation at the top of the function
is indeed not freed on the unlock_abort path. Will add a
pte_free(vma->vm_mm, pgtable).
Since this patch is more of Cleanup on PMD checks and
Warnings Is it ok if I send different patch to address
this potential leak issues or need it in this revision
itself?
Thanks,
Sunny Patel