[PATCH 7/8] MIPS: malta-init: bound default console command-line append

From: Pengpeng Hou

Date: Sat Apr 04 2026 - 22:34:48 EST


console_config() appends a synthesized console= option to fw_getcmdline()
with unchecked strcat() when the firmware command line does not already
provide one. If the existing command line is near full, that append can
overflow the fixed command-line buffer.

Switch the default console append to bounded concatenation.

Signed-off-by: Pengpeng Hou <pengpeng@xxxxxxxxxxx>
---
arch/mips/mti-malta/malta-init.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/arch/mips/mti-malta/malta-init.c b/arch/mips/mti-malta/malta-init.c
index 82b0fd8576a2..fb782b1a3f6e 100644
--- a/arch/mips/mti-malta/malta-init.c
+++ b/arch/mips/mti-malta/malta-init.c
@@ -78,13 +78,14 @@ static void __init console_config(void)
setup_earlycon(console_string);
}

- if ((strstr(fw_getcmdline(), "console=")) == NULL) {
- sprintf(console_string, " console=ttyS0,%d%c%c%c", baud,
- parity, bits, flow);
- strcat(fw_getcmdline(), console_string);
- pr_info("Config serial console:%s\n", console_string);
+ if ((strstr(fw_getcmdline(), "console=")) == NULL) {
+ sprintf(console_string, " console=ttyS0,%d%c%c%c", baud,
+ parity, bits, flow);
+ strlcat(fw_getcmdline(), console_string,
+ COMMAND_LINE_SIZE);
+ pr_info("Config serial console:%s\n", console_string);
+ }
}
-}
#endif

static void __init mips_nmi_setup(void)
--
2.50.1 (Apple Git-155)