From: Catalin Marinas <catalin.marinas@arm.com>
To: Thorsten Blum <blum@kernel.org>
Cc: Will Deacon <will@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Oliver Upton <oupton@kernel.org>,
Robin Murphy <robin.murphy@arm.com>,
Yureka Lilian <yureka@cyberchaos.dev>,
Marc Zyngier <maz@kernel.org>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] arm64: idreg-override: Use property length in get_bootargs_cmdline()
Date: Tue, 27 Oct 2026 14:39:00 +0000 [thread overview]
Message-ID: <auC3hPZEu7zUPXoe@arm.com> (raw)
In-Reply-To: <20261015192810.395975-2-blum@kernel.org>
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@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@arm.com>
prev parent reply other threads:[~2026-10-27 14:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 19:28 Thorsten Blum
2026-10-27 14:39 ` Catalin Marinas [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=auC3hPZEu7zUPXoe@arm.com \
--to=catalin.marinas@arm.com \
--cc=blum@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=oupton@kernel.org \
--cc=robin.murphy@arm.com \
--cc=will@kernel.org \
--cc=yureka@cyberchaos.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®