Skip to content

Commit 0f5e4ad

Browse files
Song Shuairppt
authored andcommitted
memblock: report failures when memblock_can_resize is not set
The callers of memblock_reserve() do not check the return value presuming that memblock_reserve() always succeeds, but there are cases where it may fail. Having numerous memblock reservations at early boot where memblock_can_resize is unset may exhaust the INIT_MEMBLOCK_REGIONS sized memblock.reserved regions array and an attempt to double this array via memblock_double_array() will fail and will return -1 to the caller. When this happens the system crashes anyway, but it's hard to identify the reason for the crash. Add a panic message to memblock_double_array() to aid debugging of the cases when too many regions are reserved before memblock can resize memblock.reserved array. Link: https://lore.kernel.org/linux-kernel/20230614131746.3670303-1-songshuaishuai@tinylab.org/ Signed-off-by: Song Shuai <songshuaishuai@tinylab.org> Link: https://lore.kernel.org/r/20230624032607.921173-1-songshuaishuai@tinylab.org Signed-off-by: Mike Rapoport (IBM) <rppt@kernel.org>
1 parent 06c2afb commit 0f5e4ad

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mm/memblock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ static int __init_memblock memblock_double_array(struct memblock_type *type,
419419
* of memory that aren't suitable for allocation
420420
*/
421421
if (!memblock_can_resize)
422-
return -1;
422+
panic("memblock: cannot resize %s array\n", type->name);
423423

424424
/* Calculate new doubled size */
425425
old_size = type->max * sizeof(struct memblock_region);

0 commit comments

Comments
 (0)