Skip to content

Commit 7a329ed

Browse files
ddissbrauner
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent 225034c commit 7a329ed

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

init/initramfs.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,6 @@ char * __init unpack_to_rootfs(char *buf, unsigned long len)
511511
long written;
512512
decompress_fn decompress;
513513
const char *compress_name;
514-
static __initdata char msg_buf[64];
515514
struct {
516515
char header[CPIO_HDRLEN];
517516
char symlink[PATH_MAX + N_ALIGN(PATH_MAX) + 1];
@@ -552,12 +551,9 @@ char * __init unpack_to_rootfs(char *buf, unsigned long len)
552551
if (res)
553552
error("decompressor failed");
554553
} else if (compress_name) {
555-
if (!message) {
556-
snprintf(msg_buf, sizeof msg_buf,
557-
"compression method %s not configured",
558-
compress_name);
559-
message = msg_buf;
560-
}
554+
pr_err("compression method %s not configured\n",
555+
compress_name);
556+
error("decompressor failed");
561557
} else
562558
error("invalid magic at start of compressed archive");
563559
if (state != Reset)

0 commit comments

Comments
 (0)