initramfs: avoid static buffer for error message

The dynamic error message printed if CONFIG_RD_$ALG compression support
is missing needn't be propagated up to the caller via a static buffer.
Print it immediately via pr_err() and set @message to a const string to
flag error.

Before:
   text    data     bss     dec     hex filename
   8006    1118       8    9132    23ac init/initramfs.o

After:
   text    data     bss     dec     hex filename
   7938    1022       8    8968    2308 init/initramfs.o

Signed-off-by: David Disseldorp <ddiss@suse.de>
Link: https://lore.kernel.org/r/20250304061020.9815-9-ddiss@suse.de
Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
David Disseldorp 2025-03-04 16:57:51 +11:00 committed by Christian Brauner
parent 225034cd51
commit 7a329ed2de
No known key found for this signature in database
GPG Key ID: 91C61BC06578DCA2

View File

@ -511,7 +511,6 @@ char * __init unpack_to_rootfs(char *buf, unsigned long len)
long written;
decompress_fn decompress;
const char *compress_name;
static __initdata char msg_buf[64];
struct {
char header[CPIO_HDRLEN];
char symlink[PATH_MAX + N_ALIGN(PATH_MAX) + 1];
@ -552,12 +551,9 @@ char * __init unpack_to_rootfs(char *buf, unsigned long len)
if (res)
error("decompressor failed");
} else if (compress_name) {
if (!message) {
snprintf(msg_buf, sizeof msg_buf,
"compression method %s not configured",
compress_name);
message = msg_buf;
}
pr_err("compression method %s not configured\n",
compress_name);
error("decompressor failed");
} else
error("invalid magic at start of compressed archive");
if (state != Reset)