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

From: Andrew Morton

Date: Tue Mar 31 2026 - 16:15:27 EST


On Tue, 31 Mar 2026 19:37:24 +0800 Muchun Song <songmuchun@xxxxxxxxxxxxx> 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:
https://sashiko.dev/#/patchset/20260331113724.2080833-1-songmuchun@xxxxxxxxxxxxx