Skip to contentSkip to conversation

of: print warning when cmdline overflows from bootargs

PATCH In review Enlin Mu 3 participants 4 messages Nov 5, 2025 – Dec 2, 2025 Device tree

lore
Share & tools
lore

Enlin Mu

author
#0 lore raw

PATCH 1/1 of: print warning when cmdline overflows from bootargs

From: Enlin Mu <[email protected]>

add debug info. sometimes cmdline in dts is too long, developers are not aware of the length limit of the cmdline, resulting in some misjudgments.

---
 drivers/of/fdt.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/of/fdt.c +2 -0
index 0edd639898a6..077799b2f565 100644
@@ -1085,6 +1085,8 @@ int __init early_init_dt_scan_chosen(char *cmdline)
 	p = of_get_flat_dt_prop(node, "bootargs", &l);
 	if (p != NULL && l > 0)
 		strscpy(cmdline, p, min(l, COMMAND_LINE_SIZE));
+	if (l > COMMAND_LINE_SIZE)
+		pr_warn("cmdline overflows from bootargs\n");
 
 handle_cmdline:
 	/*
Signature · 1 line
2.39.5
#1 lore raw
Quoted 3 lines · Enlin Mu

From: Enlin Mu <[email protected]>

add debug info. sometimes cmdline in dts is too long,

I don't see debug info here.

Please use full sentences, starting with capital letter and ending with full stop.

Please wrap commit message according to Linux coding style / submission process (neither too early nor over the limit):
https://elixir.bootlin.com/linux/v6.4-rc1/source/Documentation/process/submitting-patches.rst#L597

Quoted 13 lines

developers are not aware of the length limit of the cmdline, resulting in some misjudgments.

---
 drivers/of/fdt.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/of/fdt.c +0 -0
index 0edd639898a6..077799b2f565 100644

drivers/of/fdt.c int __init early_init_dt_scan_chosen(char *cmdline) · line 1089

Quoted 5 lines
drivers/of/fdt.c +2 -0
@@ -1085,6 +1085,8 @@ int __init early_init_dt_scan_chosen(char *cmdline)
 	p = of_get_flat_dt_prop(node, "bootargs", &l);
 	if (p != NULL && l > 0)
 		strscpy(cmdline, p, min(l, COMMAND_LINE_SIZE));
+	if (l > COMMAND_LINE_SIZE)
+		pr_warn("cmdline overflows from bootargs\n");

Why only OF early should have this warning and cmdline passed via ATAGS or in ACPI system should not?

Best regards,
Krzysztof

#2 lore raw
Quoted 5 lines · Krzysztof Kozlowski
Quoted 3 lines · Enlin Mu

From: Enlin Mu <[email protected]>

add debug info. sometimes cmdline in dts is too long,

Quoted 14 lines

I don't see debug info here.

Please use full sentences, starting with capital letter and ending with full stop.

Please wrap commit message according to Linux coding style / submission process (neither too early nor over the limit):
https://elixir.bootlin.com/linux/v6.4-rc1/source/Documentation/process/submitting-patches.rst#L597

Quoted 4 lines

developers are not aware of the length limit of the cmdline, resulting in some misjudgments.

Also, the email address here is wrong, there's previous submissions from Enlin Mu <[email protected]> which I expect is the same person...

author
#3 lore raw
In reply to Krzysztof Kozlowski
Quoted 23 lines · Krzysztof Kozlowski
Quoted 3 lines · Enlin Mu

From: Enlin Mu <[email protected]>

add debug info. sometimes cmdline in dts is too long,

I don't see debug info here.

Please use full sentences, starting with capital letter and ending with full stop.

Please wrap commit message according to Linux coding style / submission process (neither too early nor over the limit):
https://elixir.bootlin.com/linux/v6.4-rc1/source/Documentation/process/submitting-patches.rst#L597

Quoted 8 lines

developers are not aware of the length limit of the cmdline, resulting in some misjudgments.

---
  drivers/of/fdt.c | 2 ++
  1 file changed, 2 insertions(+)
Quoted 13 lines

drivers/of/fdt.c int __init early_init_dt_scan_chosen(char *cmdline) · line 1089

Quoted 10 lines
drivers/of/fdt.c +2 -0
index 0edd639898a6..077799b2f565 100644
@@ -1085,6 +1085,8 @@ int __init early_init_dt_scan_chosen(char *cmdline)
  	p = of_get_flat_dt_prop(node, "bootargs", &l);
  	if (p != NULL && l > 0)
  		strscpy(cmdline, p, min(l, COMMAND_LINE_SIZE));
+	if (l > COMMAND_LINE_SIZE)
+		pr_warn("cmdline overflows from bootargs\n");

Why only OF early should have this warning and cmdline passed via ATAGS or in ACPI system should not?

I have a Raspberry Pi 5, so I can test my patch. But for chips with other architectures, I don't have the equipment and I am not very familiar with them. If you are familiar with other architectures,
I hope you can help impore the patch or independently complete this
idea.

Thanks.

Quoted 4 lines

Best regards,
Krzysztof