Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arm64: idreg-override: Use property length in get_bootargs_cmdline()
@ 2026-10-15 19:28 Thorsten Blum
  0 siblings, 0 replies; only message in thread
From: Thorsten Blum @ 2026-10-15 19:28 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Mark Rutland, Oliver Upton,
	Robin Murphy, Yureka Lilian, Marc Zyngier
  Cc: Thorsten Blum, linux-arm-kernel, linux-kernel

fdt_getprop() already provides the length of the bootargs property. Use
it to reject a zero-length property before dereferencing it, and test
the first byte directly instead of calling strlen().

Signed-off-by: Thorsten Blum <blum@kernel.org>
---
 arch/arm64/kernel/pi/idreg-override.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/arm64/kernel/pi/idreg-override.c b/arch/arm64/kernel/pi/idreg-override.c
index acaf56234973..588c8af2a567 100644
--- a/arch/arm64/kernel/pi/idreg-override.c
+++ b/arch/arm64/kernel/pi/idreg-override.c
@@ -383,15 +383,17 @@ static __init const u8 *get_bootargs_cmdline(const void *fdt, int node)
 {
 	static char const bootargs[] __initconst = "bootargs";
 	const u8 *prop;
+	int len;
 
 	if (node < 0)
 		return NULL;
 
-	prop = fdt_getprop(fdt, node, bootargs, NULL);
-	if (!prop)
+	prop = fdt_getprop(fdt, node, bootargs, &len);
+	/* No bootargs for a missing, zero-length, or empty-string property. */
+	if (!prop || !len || !*prop)
 		return NULL;
 
-	return strlen(prop) ? prop : NULL;
+	return prop;
 }
 
 static __init void parse_cmdline(const void *fdt, int chosen)


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-10-15 19:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-15 19:28 [PATCH] arm64: idreg-override: Use property length in get_bootargs_cmdline() Thorsten Blum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox