milos-linux/drivers/base
Georgi Djakov 059ac6252a drivers/base/memory: set mem->altmap after successful device registration
commit a2b8d7827f48ee54a686cb80e4a1d0ff954ec42a upstream.

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.

Link: https://lore.kernel.org/20260514092657.3057141-1-georgi.djakov@oss.qualcomm.com
Fixes: 1a8c64e110 ("mm/memory_hotplug: embed vmem_altmap details in memory block")
Signed-off-by: Georgi Djakov <georgi.djakov@oss.qualcomm.com>
Acked-by: Oscar Salvador (SUSE) <osalvador@kernel.org>
Cc: Vishal Verma <vishal.l.verma@intel.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Richard Cheng <icheng@nvidia.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Georgi Djakov <djakov@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-06-27 11:08:17 +01:00
..
firmware_loader Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
power thermal: core: Suspend thermal zones later and resume them earlier 2026-04-08 12:30:31 +02:00
regmap regmap: reject volatile update_bits() in cache-only mode 2026-05-28 15:15:46 +01:00
test
arch_numa.c
arch_topology.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
attribute_container.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
auxiliary.c ACPI support updates for 7.1-rc1 2026-04-13 19:25:07 -07:00
auxiliary_sysfs.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
base.h driver core: make software nodes available earlier 2026-04-04 00:33:49 +02:00
bus.c driver core: reject devices with unregistered buses 2026-06-19 13:50:57 +02:00
cacheinfo.c Convert remaining multi-line kmalloc_obj/flex GFP_KERNEL uses 2026-02-22 08:26:33 -08:00
class.c kernfs: pass struct ns_common instead of const void * for namespace tags 2026-04-09 14:36:52 +02:00
component.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
container.c
core.c Driver core fixes for 7.1-rc1 2026-04-19 12:58:08 -07:00
cpu.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
dd.c Driver core fixes for 7.1-rc1 2026-04-19 12:58:08 -07:00
devcoredump.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
devres.c devres: rename and export set_node_dbginfo() 2026-03-18 00:02:59 +01:00
devtmpfs.c devtmpfs: Replace simple_strtoul with kstrtoint in mount_param 2026-01-16 16:44:43 +01:00
driver.c
faux.c driver core: faux: fix root device registration 2026-06-19 13:50:57 +02:00
firmware.c
hypervisor.c
init.c driver core: make software nodes available earlier 2026-04-04 00:33:49 +02:00
isa.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
Kconfig driver core: Make deferred_probe_timeout default a Kconfig option 2026-03-30 20:45:27 +02:00
Makefile Revert "revocable: Add Kunit test cases" 2026-02-06 16:08:48 +01:00
map.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
memory.c drivers/base/memory: set mem->altmap after successful device registration 2026-06-27 11:08:17 +01:00
module.c
node.c mm: add gpu active/reclaim per-node stat counters (v2) 2026-04-08 06:52:47 +10:00
physical_location.c Convert more 'alloc_obj' cases to default GFP_KERNEL arguments 2026-02-21 20:03:00 -08:00
physical_location.h
pinctrl.c driver core: make pinctrl_bind_pins() private 2026-01-19 00:34:44 +01:00
platform-msi.c
platform.c driver core: platform: remove software node on release() 2026-05-14 00:09:09 +02:00
property.c Driver core fixes for 7.1-rc1 2026-04-19 12:58:08 -07:00
soc.c base: soc: rename and export soc_device_get_machine() 2026-03-12 16:18:49 +01:00
swnode.c Driver core fixes for 7.1-rc1 2026-04-19 12:58:08 -07:00
syscore.c syscore: Pass context data to callbacks 2025-11-14 10:01:52 +01:00
topology.c
trace.c
trace.h
transport_class.c SCSI misc on 20260212 2026-02-12 15:43:02 -08:00