From: Alban Bedel <alban.bedel@lht.dlh.de>
To: Krzysztof Kozlowski <krzk@kernel.org>
Cc: devicetree@vger.kernel.org, Rob Herring <robh@kernel.org>,
Saravana Kannan <saravanak@kernel.org>,
driver-core@lists.linux.dev, linux-kernel@vger.kernel.org,
Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>,
Alban Bedel <alban.bedel@lht.dlh.de>
Subject: Re: [PATCH] of: property: Fix of_fwnode_get_reference_args() with negative index
Date: Mon, 15 Jun 2026 11:33:30 +0200 [thread overview]
Message-ID: <20260615113330.11406fbd@OMT-CWNXR4TFW5-LHT> (raw)
In-Reply-To: <20260615-obedient-axolotl-of-argument-fb55ef@quoll>
On Mon, 15 Jun 2026 08:33:32 +0200
Krzysztof Kozlowski <krzk@kernel.org> wrote:
> On Thu, Jun 11, 2026 at 12:28:06PM +0200, Alban Bedel wrote:
> > fwnode_property_get_reference_args() should return -ENOENT when an out
> > of bound index is passed. An issue arised with the OF backend because
> > the OF API use signed indexes while the fwnode API use unsigned ones.
> > When an index value greater the INT_MAX was passed to the OF backend
> > it got casted to a negative value and it returned -EINVAL instead of
>
> INT_MAX is not out of bound for this function. It is invalid value,
> because OF code expects signed.
But this is fwnode code, it use the OF API but it should implement the
fwnode API which, unlike the OF API, use unsigned index.
> > -ENOENT. This patch add a check to of_fwnode_get_reference_args() to
> > catch negative index before they are passed to the OF API and return
> > -ENOENT right away.
>
> I do not understand why are you fixing this issue that way. For this
> API, the INT_MAX is correct value, but you claim that it is wrong and
> should be ENOENT (even if there is entry).
>
> Fine, if this is not a correct value, then EINVAL.
Indices larger than INT_MAX are valid in the fwnode API, so returning
-EINVAL is not appropriate here.
> But more important I think this should be just fixed in different way -
> why index in OF calls is signed in the first place? All indices are
> supposed to be unsigned in general, because that is both logical and
> readable when accessing arrays.
I agree that would be the better fix in the long run. But that would
impact a lot more code and I found it difficult to ensure it would not
potentially break some of its users.
Alban
next prev parent reply other threads:[~2026-06-15 9:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-11 10:28 Alban Bedel
2026-06-15 6:33 ` Krzysztof Kozlowski
2026-06-15 9:33 ` Alban Bedel [this message]
2026-06-15 9:54 ` Krzysztof Kozlowski
2026-06-15 11:47 ` Alban Bedel
2026-06-16 4:01 ` Krzysztof Kozlowski
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=20260615113330.11406fbd@OMT-CWNXR4TFW5-LHT \
--to=alban.bedel@lht.dlh.de \
--cc=devicetree@vger.kernel.org \
--cc=driver-core@lists.linux.dev \
--cc=krzk@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh@kernel.org \
--cc=saravanak@kernel.org \
--cc=tommaso.merciai.xr@bp.renesas.com \
/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®