From: Kyle Hendry <khendry@reliablecontrols.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: "Clément Léger" <clement.leger@bootlin.com>,
"Heiner Kallweit" <hkallweit1@gmail.com>,
"Russell King" <linux@armlinux.org.uk>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Lad Prabhakar" <prabhakar.mahadev-lad.rj@bp.renesas.com>,
linux-renesas-soc@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/2] net: pcs: rzn1-miic: Verify port number from dtb
Date: Mon, 14 Sep 2026 09:37:16 -0700 [thread overview]
Message-ID: <3b638508-6c03-47e5-80ef-49b05961c9cb@reliablecontrols.com> (raw)
In-Reply-To: <81869e14-2dff-4bff-b2b4-07185c4e9086@lunn.ch>
On 02-Sep-26 11:50, Andrew Lunn wrote:
> On Wed, Sep 02, 2026 at 11:37:36AM -0700, Kyle Hendry via B4 Relay wrote:
>> From: Kyle Hendry <khendry@reliablecontrols.com>
>>
>> Add check to make sure port number is in range before writing
>> to dt_val array
>>
>> Signed-off-by: Kyle Hendry <khendry@reliablecontrols.com>
>> ---
>> drivers/net/pcs/pcs-rzn1-miic.c | 6 ++++++
>> 1 file changed, 6 insertions(+)
>>
>> diff --git a/drivers/net/pcs/pcs-rzn1-miic.c b/drivers/net/pcs/pcs-rzn1-miic.c
>> index c50b65d064fa..3ee40eb9d545 100644
>> --- a/drivers/net/pcs/pcs-rzn1-miic.c
>> +++ b/drivers/net/pcs/pcs-rzn1-miic.c
>> @@ -692,6 +692,12 @@ static int miic_parse_dt(struct miic *miic, u32 *mode_cfg)
>> if (of_property_read_u32(conv, "reg", &port))
>> continue;
>>
>> + if (port < miic->of_data->miic_port_start || port > miic->of_data->miic_port_max) {
>> + dev_err(miic->dev, "Port number out of range: %d\n", port);
>> + kfree(dt_val);
>> + return -EINVAL;
>> + }
>> +
>
> While reviewing this, i noticed:
>
> /* Adjust for 0 based index */
> dt_val[port + !miic->of_data->miic_port_start] = conf;
>
> Is the ! correct?
>
> Andrew
Yes, this is correct because dt_val[1] is where the port config entries
start.
Depending on the SoC, the port numbering might be 0 or 1 based, so this
prevents the input config entry at dt_val[0] from being overwritten. The
logic works out to the same as:
index = port + 1 - miic->of_data->miic_port_start
-Kyle
next prev parent reply other threads:[~2026-09-14 16:37 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-02 18:37 [PATCH v3 0/2] net: pcs: rzn1-miic: Fix config array initialization Kyle Hendry via B4 Relay
2026-09-02 18:37 ` [PATCH v3 1/2] " Kyle Hendry via B4 Relay
2026-09-07 19:26 ` Lad, Prabhakar
2026-09-02 18:37 ` [PATCH v3 2/2] net: pcs: rzn1-miic: Verify port number from dtb Kyle Hendry via B4 Relay
2026-09-02 18:50 ` Andrew Lunn
2026-09-14 16:37 ` Kyle Hendry [this message]
2026-09-14 17:08 ` Andrew Lunn
2026-09-02 22:12 ` Jakub Kicinski
2026-09-07 19:39 ` Lad, Prabhakar
2026-09-07 20:49 ` Andrew Lunn
2026-09-07 21:23 ` Lad, Prabhakar
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=3b638508-6c03-47e5-80ef-49b05961c9cb@reliablecontrols.com \
--to=khendry@reliablecontrols.com \
--cc=andrew@lunn.ch \
--cc=clement.leger@bootlin.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=prabhakar.mahadev-lad.rj@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