Files
erofs-linux/drivers/base
Georgi Djakov a2b8d7827f 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.

Link: https://lore.kernel.org/[email protected]
Fixes: 1a8c64e110 ("mm/memory_hotplug: embed vmem_altmap details in memory block")
Signed-off-by: Georgi Djakov <[email protected]>
Acked-by: Oscar Salvador (SUSE) <[email protected]>
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]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
2026-06-02 15:22:33 -07:00
..
…
…
…
…
…
…