Re: [PATCH] of: property: Fix of_fwnode_get_reference_args() with negative index

From: Krzysztof Kozlowski

Date: Tue Jun 16 2026 - 00:02:08 EST


On 15/06/2026 13:47, Alban Bedel wrote:
> On Mon, 15 Jun 2026 11:54:01 +0200
> Krzysztof Kozlowski <krzk@xxxxxxxxxx> wrote:
>>> Indices larger than INT_MAX are valid in the fwnode API, so returning
>>> -EINVAL is not appropriate here.
>>>
>>
>> Then neither ENOENT are.
>>
>> But really, EINVAL is correct here. This is OF implementation, so this
>> implementation decides what is EINVAL and what is right. Not fwnode API.
>
> I think there is a missunderstanding here. The function we are talking
> about, of_fwnode_get_reference_args(), is the OF backed implementation
> of fwnode_property_get_reference_args(). As such it must follow the API
> documented by fwnode_property_get_reference_args() which list the
> following return values:
>
> * Return: %0 on success
> * %-ENOENT when the index is out of bounds, the index has an empty
> * reference or the property was not found
> * %-EINVAL on parse error
> * %-ENOTCONN when the remote firmware node exists but has not been
> * registered yet
>
> It is not explicitly documented what should be returned if the index is
> not representable in the backend, but considering it out of bound seems
> to be the most sensible thing to do.
>

I agree, I did not consider the docs for
fwnode_property_get_reference_args().

Please send v2 fixing the comment style and with:

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@xxxxxxxxxxxxxxxx>


Best regards,
Krzysztof