Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Rio and committed by
Andrew Morton
48d76a82 a9dff0d0

+3 -7
+3 -7
kernel/panic.c
··· 865 865 */ 866 866 #define INIT_TAINT_BUF_MAX 350 867 867 868 - static char init_taint_buf[INIT_TAINT_BUF_MAX]; 869 - static char *taint_buf = init_taint_buf; 868 + static char init_taint_buf[INIT_TAINT_BUF_MAX] __initdata; 869 + static char *taint_buf __refdata = init_taint_buf; 870 870 static size_t taint_buf_size = INIT_TAINT_BUF_MAX; 871 871 872 872 static __init int alloc_taint_buf(void) ··· 887 887 buf = kmalloc(size, GFP_KERNEL); 888 888 889 889 if (!buf) { 890 - /* Allocation may fail; this warning explains possibly 891 - * truncated taint strings 892 - */ 893 - pr_warn_once("taint string buffer allocation failed, using fallback buffer\n"); 894 - return 0; 890 + panic("Failed to allocate taint string buffer"); 895 891 } 896 892 897 893 taint_buf = buf;