diff options
| author | Rio <rioo.tsukatsukii@gmail.com> | 2026-02-23 09:29:14 +0530 |
|---|---|---|
| committer | Andrew Morton <akpm@linux-foundation.org> | 2026-03-27 21:19:33 -0700 |
| commit | 48d76a8282c9d99ec123d5f09cf6e485e5cb8734 (patch) | |
| tree | e376a2dc8d923cc74edda7b362c72deecf0c4ea6 /kernel/panic.c | |
| parent | a9dff0d0d11ce9aeebdd52ecf1469895e336c87e (diff) | |
kernel/panic: mark init_taint_buf as __initdata and panic instead of warning in alloc_taint_buf()
However there's a convention of assuming that __init-time allocations
cannot fail. Because if a kmalloc() were to fail at this time, the kernel
is hopelessly messed up anyway. So simply panic() if that kmalloc failed,
then make that 350-byte buffer __initdata.
Link: https://lkml.kernel.org/r/20260223035914.4033-1-rioo.tsukatsukii@gmail.com
Signed-off-by: Rio <rioo.tsukatsukii@gmail.com>
Cc: Joel Granados <joel.granados@kernel.org>
Cc: Petr Mladek <pmladek@suse.com>
Cc: Wang Jinchao <wangjinchao600@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'kernel/panic.c')
| -rw-r--r-- | kernel/panic.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/kernel/panic.c b/kernel/panic.c index 5d498ff8a18b..20feada5319d 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -865,8 +865,8 @@ static void print_tainted_seq(struct seq_buf *s, bool verbose) */ #define INIT_TAINT_BUF_MAX 350 -static char init_taint_buf[INIT_TAINT_BUF_MAX]; -static char *taint_buf = init_taint_buf; +static char init_taint_buf[INIT_TAINT_BUF_MAX] __initdata; +static char *taint_buf __refdata = init_taint_buf; static size_t taint_buf_size = INIT_TAINT_BUF_MAX; static __init int alloc_taint_buf(void) @@ -887,11 +887,7 @@ static __init int alloc_taint_buf(void) buf = kmalloc(size, GFP_KERNEL); if (!buf) { - /* Allocation may fail; this warning explains possibly - * truncated taint strings - */ - pr_warn_once("taint string buffer allocation failed, using fallback buffer\n"); - return 0; + panic("Failed to allocate taint string buffer"); } taint_buf = buf; |
