FAILED: patch "[PATCH] drivers/base/memory: set mem->altmap after successful device" failed to apply to 6.6-stable tree
Subsystems (3)
[email protected]
maintainerThe 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.
drivers/base/memory.c +2 -1
@@ -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 stateif (ret)return ret; + mem->altmap = altmap; +if (group) { mem->group = group;list_add (&mem->group_next, &group->memory_blocks);
Sasha Levin
maintainerPATCH 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.
--- drivers/base/memory.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/base/memory.c +2 -1
@@ -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