[PATCH] arm64: idreg-override: Use property length in get_bootargs_cmdline()
Catalin Marinas
catalin.marinas at arm.com
Tue Oct 27 07:39:00 PDT 2026
On Thu, Oct 15, 2026 at 09:28:08PM +0200, Thorsten Blum wrote:
> 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 at 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;
I think the patch makes sense. In theory we may have a value-less
bootargs property and prop points to the next token (or some
FDT_END_NODE) but they would all have 0 as the first byte, so the
strlen() check would catch it. Anyway, the above is clearer, so:
Reviewed-by: Catalin Marinas <catalin.marinas at arm.com>
More information about the linux-arm-kernel
mailing list