public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/sparse: fix preinited section_mem_map clobbering on failure path
@ 2026-03-31 11:37 Muchun Song
  2026-03-31 18:34 ` Donet Tom
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Muchun Song @ 2026-03-31 11:37 UTC (permalink / raw)
  To: Andrew Morton, David Hildenbrand
  Cc: Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
	Suren Baghdasaryan, Michal Hocko, Frank van der Linden, linux-mm,
	linux-kernel, muchun.song, Muchun Song

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.

Fixes: d65917c42373 ("mm/sparse: allow for alternate vmemmap section init at boot")
Signed-off-by: Muchun Song <songmuchun@bytedance.com>
---
 mm/sparse.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/mm/sparse.c b/mm/sparse.c
index c2eb36bfb86d..3a14b733bf71 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -584,7 +584,6 @@ static void __init sparse_init_nid(int nid, unsigned long pnum_begin,
 		ms = __nr_to_section(pnum);
 		if (!preinited_vmemmap_section(ms))
 			ms->section_mem_map = 0;
-		ms->section_mem_map = 0;
 	}
 }
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2026-04-02 12:12 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-31 11:37 [PATCH] mm/sparse: fix preinited section_mem_map clobbering on failure path Muchun Song
2026-03-31 18:34 ` Donet Tom
2026-04-01  2:28   ` Muchun Song
2026-03-31 20:10 ` Andrew Morton
2026-03-31 21:06   ` David Hildenbrand (Arm)
2026-04-01  2:37   ` Muchun Song
2026-03-31 20:42 ` David Hildenbrand (Arm)
2026-04-01  2:41   ` Muchun Song
2026-04-01  7:25     ` David Hildenbrand (Arm)
2026-04-01  7:28       ` Muchun Song
2026-04-02  7:37       ` Donet Tom
2026-04-02  7:56         ` David Hildenbrand (Arm)
2026-04-02 12:12           ` Donet Tom

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox