memblock: fix crash when reserved memory is not added to memory

After commit 61167ad5fe ("mm: pass nid to reserve_bootmem_region()")
nid of a reserved region is used by init_reserved_page() (with
CONFIG_DEFERRED_STRUCT_PAGE_INIT=y) to access node strucure.
In many cases the nid of the reserved memory is not set and this causes
a crash.

When the nid of a reserved region is not set, fall back to
early_pfn_to_nid(), so that nid of the first_online_node will be passed
to init_reserved_page().

Fixes: 61167ad5fe ("mm: pass nid to reserve_bootmem_region()")
Signed-off-by: Yajun Deng <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
[rppt: massaged the commit message]
Signed-off-by: Mike Rapoport (IBM) <[email protected]>
This commit is contained in:
Yajun Deng authored and Mike Rapoport (IBM) committed 2024-01-19 10:53:59 +02:00
1 parent 0dd3ee3112
commit 6a9531c3a8
1 file changed
+3
+3
View File
@@ -2141,6 +2141,9 @@ static void __init memmap_init_reserved_pages(void)
start = region->base;
end = start + region->size;
if (nid == NUMA_NO_NODE || nid >= MAX_NUMNODES)
nid = early_pfn_to_nid(PFN_DOWN(start));
reserve_bootmem_region(start, end, nid);
}
}