public inbox for driver-core@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH 1/2] mm/memory_hotplug: fix memory block reference leak on remove
@ 2026-04-26 14:44 Muchun Song
  2026-04-26 14:44 ` [PATCH 2/2] drivers/base/memory: fix memory block reference leak in poison accounting Muchun Song
  2026-04-27  7:49 ` [PATCH 1/2] mm/memory_hotplug: fix memory block reference leak on remove Oscar Salvador
  0 siblings, 2 replies; 8+ messages in thread
From: Muchun Song @ 2026-04-26 14:44 UTC (permalink / raw)
  To: David Hildenbrand, Oscar Salvador, Andrew Morton,
	Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich
  Cc: muchun.song, Ying Huang, Dan Williams, Vishal Verma, Miaohe Lin,
	Naoya Horiguchi, linux-mm, linux-cxl, driver-core, linux-kernel,
	Muchun Song, stable

remove_memory_blocks_and_altmaps() looks up each memory block with
find_memory_block(), which acquires a reference to the memory block
device.

That reference is never dropped on this path, resulting in a leaked
device reference when removing memory blocks and their altmaps. Drop
the reference after retrieving mem->altmap and clearing mem->altmap,
before removing the memory block device.

Fixes: 6b8f0798b85a ("mm/memory_hotplug: split memmap_on_memory requests across memblocks")
Cc: stable@vger.kernel.org
Signed-off-by: Muchun Song <songmuchun@bytedance.com>
---
 mm/memory_hotplug.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 2a943ec57c85..4426abb05655 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -1422,6 +1422,7 @@ static void remove_memory_blocks_and_altmaps(u64 start, u64 size)
 
 		altmap = mem->altmap;
 		mem->altmap = NULL;
+		put_device(&mem->dev);
 
 		remove_memory_block_devices(cur_start, memblock_size);
 

base-commit: 7080e32d3f09d8688c4a87d81bdcc71f7f606b16
-- 
2.20.1


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

end of thread, other threads:[~2026-04-27  9:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-26 14:44 [PATCH 1/2] mm/memory_hotplug: fix memory block reference leak on remove Muchun Song
2026-04-26 14:44 ` [PATCH 2/2] drivers/base/memory: fix memory block reference leak in poison accounting Muchun Song
2026-04-27  9:13   ` Miaohe Lin
2026-04-27  9:16     ` Muchun Song
2026-04-27  9:28       ` David Hildenbrand (Arm)
2026-04-27  7:49 ` [PATCH 1/2] mm/memory_hotplug: fix memory block reference leak on remove Oscar Salvador
2026-04-27  8:02   ` Muchun Song
2026-04-27  8:13     ` Oscar Salvador

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