mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-11-01 06:46:35 +01:00
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]>