Re: [PATCH] mm/migrate_device: Cleanup up PMD Checks and warnings
From: Andrew Morton
Date: Fri Apr 24 2026 - 14:29:54 EST
On Fri, 24 Apr 2026 22:52:08 +0530 Sunny Patel <nueralspacetech@xxxxxxxxx> wrote:
> 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
>
> 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?
A separate patch, please.
It's best to prepare the bugfix patch against current Linus mainline,
then any cleanups come on top of the bugfix.
Thanks.