Re: [PATCH] of: base: Handle optional argument in of_parse_phandle_with_args_map()
From: Rob Herring (Arm)
Date: Wed Jul 22 2026 - 10:04:50 EST
On Thu, 16 Jul 2026 12:51:12 +0200, Miquel Raynal (Schneider Electric) wrote:
> The kernel doc claims out_args is optional. In practice, the function
> unconditionally dereferences it. It feels like calling this function
> with a NULL out_args argument may be a valid use case (in order to know
> if the lookup would work, even though we might not care about the
> result), even though in practice there seem to be no actual user of that
> possibility. All callers give an on-stack object to fill.
>
> There are two ways out: either we drop the "optional" wording from the
> kernel doc, or we handle the NULL case properly. Since handling this
> case goes in favor of more harmonization of the semantics and since
> of_parse_phandle_with_args() actually do handle that situation
> correctly, let's handle it in the _map() case as well.
>
> Use a local on-stack object in case no argument is passed. This way, we
> actually go through the same logic as if there was an argument. We may
> however return rather early, since the second part of the function is
> dedicated at filling that argument.
>
> Reported-by: Sashiko <sashiko-bot@xxxxxxxxxx>
> Closes: https://lore.kernel.org/all/20260710183359.61D3A1F000E9@xxxxxxxxxxxxxxx/
> Signed-off-by: Miquel Raynal (Schneider Electric) <miquel.raynal@xxxxxxxxxxx>
> ---
> The number of passing unit tests is identical before/after the commit:
> [ 10.774120] ### dt-test ### end of unittest - 426 passed, 1 failed
> ---
> drivers/of/base.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
Applied, thanks!