Re: [PATCH] mm/sparse: fix preinited section_mem_map clobbering on failure path

Andrew Morton
2026-03-31T20:10:59Z

On Tue, 31 Mar 2026 19:37:24 +0800 Muchun Song <songmuchun@bytedance.com> wrote:

> sparse_init_nid() is careful to leave alone every section whose vmemmap
> has already been set up by sparse_vmemmap_init_nid_early(); it only
> clears section_mem_map for the rest:
>
> if (!preinited_vmemmap_section(ms))
> ms->section_mem_map = 0;
>
> A leftover line after that conditional block
>
> ms->section_mem_map = 0;
>
> was supposed to be deleted but was missed in the failure path, causing the
> field to be overwritten for all sections when memory allocation fails,
> effectively destroying the pre-initialization check.
>
> Drop the stray assignment so that preinited sections retain their
> already valid state.

Here I go again ;) Are there userspace impacts?

AI review thinks it found a different bug: