summaryrefslogtreecommitdiff
path: root/mm/memblock.c
diff options
context:
space:
mode:
authorSong Shuai <songshuaishuai@tinylab.org>2023-06-24 11:26:07 +0800
committerMike Rapoport (IBM) <rppt@kernel.org>2023-09-28 09:04:33 +0300
commite96c6b8f212a510c9b22362de519f6e1d7920de5 (patch)
treed6cbd48a68c88d396566a23681a0a370fc5af5d2 /mm/memblock.c
parent6465e260f48790807eef06b583b38ca9789b6072 (diff)
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>
Diffstat (limited to 'mm/memblock.c')
-rw-r--r--mm/memblock.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/mm/memblock.c b/mm/memblock.c
index 913b2520a9a0..0863222af4a4 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -424,7 +424,7 @@ static int __init_memblock memblock_double_array(struct memblock_type *type,
* of memory that aren't suitable for allocation
*/
if (!memblock_can_resize)
- return -1;
+ panic("memblock: cannot resize %s array\n", type->name);
/* Calculate new doubled size */
old_size = type->max * sizeof(struct memblock_region);