[PATCH 8/8] MIPS: malta-setup: bound pci_clock command-line append
From: Pengpeng Hou
Date: Sat Apr 04 2026 - 22:34:52 EST
pci_clock_check() appends a synthesized pci_clock= option by advancing to
the end of fw_getcmdline() and calling sprintf() in place. If the command
line is already near full, that write can run past the fixed boot
command-line buffer.
Format the option into a small temporary buffer and append it with
bounded concatenation instead.
Signed-off-by: Pengpeng Hou <pengpeng@xxxxxxxxxxx>
---
arch/mips/mti-malta/malta-setup.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/arch/mips/mti-malta/malta-setup.c b/arch/mips/mti-malta/malta-setup.c
index 816570514c37..07c9f1b9bed7 100644
--- a/arch/mips/mti-malta/malta-setup.c
+++ b/arch/mips/mti-malta/malta-setup.c
@@ -148,10 +148,12 @@ static void __init pci_clock_check(void)
return;
if (pciclock != 33) {
+ char arg[24];
+
pr_warn("WARNING: PCI clock is %dMHz, setting pci_clock\n",
pciclock);
- argptr += strlen(argptr);
- sprintf(argptr, " pci_clock=%d", pciclock);
+ snprintf(arg, sizeof(arg), " pci_clock=%d", pciclock);
+ strlcat(argptr, arg, COMMAND_LINE_SIZE);
if (pciclock < 20 || pciclock > 66)
pr_warn("WARNING: IDE timing calculations will be "
"incorrect\n");
--
2.50.1 (Apple Git-155)