]> git.ipfire.org Git - thirdparty/linux.git/commit
kernel/panic: allocate taint string buffer dynamically
authorRio <rioo.tsukatsukii@gmail.com>
Sun, 22 Feb 2026 14:08:04 +0000 (19:38 +0530)
committerAndrew Morton <akpm@linux-foundation.org>
Sat, 28 Mar 2026 04:19:33 +0000 (21:19 -0700)
commita9dff0d0d11ce9aeebdd52ecf1469895e336c87e
tree8091e0581411ef3ef92404d54cdf1f48010f91ad
parenta75d207916de0909e2244bc66a44d72fadbcf383
kernel/panic: allocate taint string buffer dynamically

The buffer used to hold the taint string is statically allocated, which
requires updating whenever a new taint flag is added.

Instead, allocate the exact required length at boot once the allocator is
available in an init function.  The allocation sums the string lengths in
taint_flags[], along with space for separators and formatting.
print_tainted() is switched to use this dynamically allocated buffer.

If allocation fails, print_tainted() warns about the failure and continues
to use the original static buffer as a fallback.

Link: https://lkml.kernel.org/r/20260222140804.22225-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>
kernel/panic.c