Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/fake-numa: fix leak of the distance table copy on errors
@ 2026-12-02 16:46 Mike Rapoport
  2026-12-02 16:54 ` David Hildenbrand (Arm)
  0 siblings, 1 reply; 2+ messages in thread
From: Mike Rapoport @ 2026-12-02 16:46 UTC (permalink / raw)
  To: Mike Rapoport
  Cc: Andrew Morton, David Hildenbrand, linux-kernel, linux-mm, Sashiko

From: "Mike Rapoport (Microsoft)" <rppt@kernel.org>

numa_emulation() copies the physical distance table before calling
fix_pxm_node_maps(), but if fix_pxm_node_maps() fails, the copy is never
freed.

This only happens with numa=fake= setups that fix_pxm_node_maps() already
warns about, and leaks a single page on systems with up to 64 nodes.

Free the copy at no_emu. memblock_free() ignores NULL, so this is safe for
the errors that happen before the table is copied.

Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/bug/linux-96a473a0-2815-4091-910e-970513fa6467
Fixes: 63db8170bf34 ("mm/fake-numa: allow later numa node hotplug")
---
 mm/numa_emulation.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/mm/numa_emulation.c b/mm/numa_emulation.c
index 55f26b22bb0be..d79b5e42b5415 100644
--- a/mm/numa_emulation.c
+++ b/mm/numa_emulation.c
@@ -546,6 +546,7 @@ void __init numa_emulation(struct numa_meminfo *numa_meminfo, int numa_dist_cnt)
 	return;
 
 no_emu:
+	memblock_free(phys_dist, phys_size);
 	numa_nodes_parsed = physnode_mask;
 	/* No emulation.  Build identity emu_nid_to_phys[] for numa_add_cpu() */
 	for (i = 0; i < ARRAY_SIZE(emu_nid_to_phys); i++)

base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
-- 
2.53.0



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

* Re: [PATCH] mm/fake-numa: fix leak of the distance table copy on errors
  2026-12-02 16:46 [PATCH] mm/fake-numa: fix leak of the distance table copy on errors Mike Rapoport
@ 2026-12-02 16:54 ` David Hildenbrand (Arm)
  0 siblings, 0 replies; 2+ messages in thread
From: David Hildenbrand (Arm) @ 2026-12-02 16:54 UTC (permalink / raw)
  To: Mike Rapoport; +Cc: Andrew Morton, linux-kernel, linux-mm, Sashiko

On 12/2/26 17:46, Mike Rapoport wrote:
> From: "Mike Rapoport (Microsoft)" <rppt@kernel.org>
> 
> numa_emulation() copies the physical distance table before calling
> fix_pxm_node_maps(), but if fix_pxm_node_maps() fails, the copy is never
> freed.
> 
> This only happens with numa=fake= setups that fix_pxm_node_maps() already
> warns about, and leaks a single page on systems with up to 64 nodes.
> 
> Free the copy at no_emu. memblock_free() ignores NULL, so this is safe for
> the errors that happen before the table is copied.
> 
> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Closes: https://sashiko.dev/bug/linux-96a473a0-2815-4091-910e-970513fa6467
> Fixes: 63db8170bf34 ("mm/fake-numa: allow later numa node hotplug")
> ---

Reviewed-by: David Hildenbrand (Arm) <david@kernel.org>

-- 
Cheers,

David


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

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

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 16:46 [PATCH] mm/fake-numa: fix leak of the distance table copy on errors Mike Rapoport
2026-12-02 16:54 ` David Hildenbrand (Arm)

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