Skip to content

Commit 5eadecd

Browse files
committed
memblock: fix crash when reserved memory is not added to memory
JIRA: https://issues.redhat.com/browse/RHEL-36126 Conflicts: backport out-of-order before commit 77e6c43 ("memblock: introduce MEMBLOCK_RSRV_NOINIT flag") where MEMBLOCK_RSRV_NOINIT is added and checked in the loop. commit 6a9531c Author: Yajun Deng <yajun.deng@linux.dev> Date: Thu Jan 18 14:18:53 2024 +0800 memblock: fix crash when reserved memory is not added to memory After commit 61167ad ("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: 61167ad ("mm: pass nid to reserve_bootmem_region()") Signed-off-by: Yajun Deng <yajun.deng@linux.dev> Link: https://lore.kernel.org/r/20240118061853.2652295-1-yajun.deng@linux.dev [rppt: massaged the commit message] Signed-off-by: Mike Rapoport (IBM) <rppt@kernel.org> Signed-off-by: Eric Chanudet <echanude@redhat.com>
1 parent 2a44683 commit 5eadecd

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

mm/memblock.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2115,6 +2115,9 @@ static void __init memmap_init_reserved_pages(void)
21152115
start = region->base;
21162116
end = start + region->size;
21172117

2118+
if (nid == NUMA_NO_NODE || nid >= MAX_NUMNODES)
2119+
nid = early_pfn_to_nid(PFN_DOWN(start));
2120+
21182121
reserve_bootmem_region(start, end, nid);
21192122
}
21202123
}

0 commit comments

Comments
 (0)