[PATCH 2/2] init: Combine blacklist entry allocations in initcall_blacklist()
From: Thorsten Blum
Date: Sun Nov 15 2026 - 09:24:21 EST
Use a flexible array member for the function name and allocate it
together with the blacklist entry. This removes the pointer and saves
one allocation call per blacklist entry.
Signed-off-by: Thorsten Blum <blum@xxxxxxxxxx>
---
init/main.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/init/main.c b/init/main.c
index db8fb6ebe830..da10f08037ef 100644
--- a/init/main.c
+++ b/init/main.c
@@ -28,6 +28,7 @@
#include <linux/init.h>
#include <linux/initrd.h>
#include <linux/memblock.h>
+#include <linux/overflow.h>
#include <linux/acpi.h>
#include <linux/bootconfig.h>
#include <linux/console.h>
@@ -1266,7 +1267,7 @@ static void __init do_ctors(void)
#ifdef CONFIG_KALLSYMS
struct blacklist_entry {
struct list_head next;
- char *buf;
+ char buf[];
};
static __initdata_or_module LIST_HEAD(blacklisted_initcalls);
@@ -1281,8 +1282,8 @@ static int __init initcall_blacklist(char *str)
size_t buf_size = strlen(str_entry) + 1;
pr_debug("blacklisting initcall %s\n", str_entry);
- entry = memblock_alloc_or_panic(sizeof(*entry), SMP_CACHE_BYTES);
- entry->buf = memblock_alloc_or_panic(buf_size, SMP_CACHE_BYTES);
+ entry = memblock_alloc_or_panic(struct_size(entry, buf, buf_size),
+ SMP_CACHE_BYTES);
strscpy(entry->buf, str_entry, buf_size);
list_add(&entry->next, &blacklisted_initcalls);
}