Skip to contentSkip to conversation

FAILED: patch "[PATCH] drivers/base/memory: set mem->altmap after successful device" failed to apply to 6.6-stable tree

PATCH New [email protected] 2 participants 2 messages Jun 25

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 6.6-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y
git checkout FETCH_HEAD
git cherry-pick -x a2b8d7827f48ee54a686cb80e4a1d0ff954ec42a
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026062557-blinker-quartered-5591@gregkh' --subject-prefix 'PATCH 6.6.y' 'HEAD^..'

Possible dependencies:

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From a2b8d7827f48ee54a686cb80e4a1d0ff954ec42a Mon Sep 17 00:00:00 2001
From: Georgi Djakov <[email protected]>
Date: Thu, 14 May 2026 02:26:57 -0700
Subject: [PATCH] drivers/base/memory: set mem->altmap after successful device
registration

If __add_memory_block() fails at xa_store() (under memory pressure for example), device_unregister() is called, which eventually triggers memory_block_release() with mem->altmap still set, causing a WARN_ON(mem->altmap). This was triggered by modifying virtio-mem driver.

Fix this by delaying the assignment of mem->altmap until after __add_memory_block() has succeeded.

Fixes 1a8c64e11043 ("mm/memory_hotplug: embed vmem_altmap details in memory block")
Cc Vishal Verma <[email protected]>
Cc Mike Rapoport <[email protected]>
Cc Richard Cheng <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc Georgi Djakov <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
drivers/base/memory.c +2 -1
index d31a421f7483..b318344426fa 100644
@@ -797,7 +797,6 @@ static int add_memory_block(unsigned long block_id, int nid, unsigned long state
 	mem->start_section_nr = block_id * sections_per_block;
 	mem->state = state;
 	mem->nid = nid;
-	mem->altmap = altmap;
 	INIT_LIST_HEAD(&mem->group_next);
 
 #ifndef CONFIG_NUMA
@@ -815,6 +814,8 @@ static int add_memory_block(unsigned long block_id, int nid, unsigned long state
 	if (ret)
 		return ret;
 
+	mem->altmap = altmap;
+
 	if (group) {
 		mem->group = group;
 		list_add(&mem->group_next, &group->memory_blocks);
maintainer
#1 lore raw

PATCH 1/1 drivers/base/memory: set mem->altmap after successful device registration

From: Georgi Djakov <[email protected]>

[ Upstream commit a2b8d7827f48ee54a686cb80e4a1d0ff954ec42a ]

If __add_memory_block() fails at xa_store() (under memory pressure for example), device_unregister() is called, which eventually triggers memory_block_release() with mem->altmap still set, causing a WARN_ON(mem->altmap). This was triggered by modifying virtio-mem driver.

Fix this by delaying the assignment of mem->altmap until after __add_memory_block() has succeeded.

Fixes 1a8c64e11043 ("mm/memory_hotplug: embed vmem_altmap details in memory block")
Cc Vishal Verma <[email protected]>
Cc Mike Rapoport <[email protected]>
Cc Richard Cheng <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc Georgi Djakov <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
---
 drivers/base/memory.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/base/memory.c +2 -1
index 9e413f522bd629..468ef9b3983cf8 100644
@@ -773,7 +773,6 @@ static int add_memory_block(unsigned long block_id, unsigned long state,
 	mem->start_section_nr = block_id * sections_per_block;
 	mem->state = state;
 	mem->nid = NUMA_NO_NODE;
-	mem->altmap = altmap;
 	INIT_LIST_HEAD(&mem->group_next);
 
 #ifndef CONFIG_NUMA
@@ -791,6 +790,8 @@ static int add_memory_block(unsigned long block_id, unsigned long state,
 	if (ret)
 		return ret;
 
+	mem->altmap = altmap;
+
 	if (group) {
 		mem->group = group;
 		list_add(&mem->group_next, &group->memory_blocks);
Signature · 1 line
2.53.0