From: netdev-bot+sashiko@kernel.org
To: khendry@reliablecontrols.com
Cc: clement.leger@bootlin.com, andrew@lunn.ch, hkallweit1@gmail.com,
linux@armlinux.org.uk, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com,
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 net-next v2 1/3] net: pcs: rzn1-miic: Fix port numbering on RZ/T2H
Date: Thu, 01 Oct 2026 12:20:59 +0000 [thread overview]
Message-ID: <179085725981.434549.8679017357220612418@kernel.org> (raw)
In-Reply-To: <20260928-miic-validate-dtb-v2-1-1ee3d33748e9@reliablecontrols.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 (1) · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] `miic_port_max` means two different things in
drivers/net/pcs/pcs-rzn1-miic.c: - `miic_create()` (line 485) treats…
Pre-existing issues:
- [Medium] In `miic_parse_dt()` (drivers/net/pcs/pcs-rzn1-miic.c), the
child node's DT "reg" value is used unchecked in two places: - It…
--
net: pcs: rzn1-miic: Fix port numbering on RZ/T2H
This commit changes miic_port_max in rzt2h_miic_of_data from 4 to 3. The
RZ/T2H ports are documented as 0 to 3.
> diff --git a/drivers/net/pcs/pcs-rzn1-miic.c b/drivers/net/pcs/pcs-rzn1-miic.c
> index cb74861e823c8..df70309c2d970 100644
> --- a/drivers/net/pcs/pcs-rzn1-miic.c
> +++ b/drivers/net/pcs/pcs-rzn1-miic.c
> @@ -838,7 +838,7 @@ static struct miic_of_data rzt2h_miic_of_data = {
> .index_to_string = rzt2h_index_to_string,
> .index_to_string_count = ARRAY_SIZE(rzt2h_index_to_string),
> .miic_port_start = 0,
> - .miic_port_max = 4,
> + .miic_port_max = 3,
[Severity: Medium]
Does this leave converter 3 out of miic_init_hw() on RZ/T2H?
This file uses miic_port_max in two ways. miic_create() treats it as the
highest valid port, inclusive:
drivers/net/pcs/pcs-rzn1-miic.c:miic_create() {
...
if (port > of_data->miic_port_max || port < of_data->miic_port_start) {
...
}
miic_init_hw() treats it as a converter count, exclusive:
drivers/net/pcs/pcs-rzn1-miic.c:miic_init_hw() {
...
for (port = 0; port < miic->of_data->miic_port_max; port++) {
miic_converter_enable(miic, port, 0);
...
}
With miic_port_max = 3 and miic_port_start = 0, the loop now covers only
ports 0 to 2. miic_converter_enable() changes only the CONVRST bit for the
port it is given. So CONVRST bit 3 (MIIC_CONVRST_PHYIF_RST(3)) is no longer
cleared at probe.
CONV3 then stays in whatever reset state the bootloader left it in while
MODCTRL is reprogrammed.
A later patch in this series, "net: pcs: rzn1-miic: Fix miic register
initialization loop", changes the loop bound to
miic_port_max - miic_port_start + 1. After that change both uses agree
again.
This patch has a Fixes: tag, so it could be backported on its own. Could
the two patches be squashed or reordered, so that neither bisect nor stable
ever sees this in-between state?
> .sw_mode_mask = GENMASK(2, 0),
> .reset_ids = rzt2h_reset_ids,
> .reset_count = ARRAY_SIZE(rzt2h_reset_ids),
[Severity: Medium]
This isn't a bug introduced by this patch, but can miic_parse_dt() write
past the end of dt_val[]?
The DT "reg" value of each converter child is used as an index with no
bounds check:
drivers/net/pcs/pcs-rzn1-miic.c:miic_parse_dt() {
...
dt_val = kmalloc_objs(*dt_val, miic->of_data->conf_conv_count);
...
/* Adjust for 0 based index */
dt_val[port + !miic->of_data->miic_port_start] = conf;
...
miic_configure_phy_link(miic, conf, port, active_low);
...
}
On RZ/T2H conf_conv_count is 5. A child with reg >= 4 therefore writes at
index 5 or higher.
The same port value also reaches BIT(port + shift) in
miic_configure_phy_link(). A large value there would be an undefined shift.
The "renesas,miic-input" value is not range checked either. When no match
table entry matches, miic_dump_conf() uses it as
of_data->conf_to_string[conf[i]].
A later patch in this series, "net: pcs: rzn1-miic: Validate dtb
configuration values", adds port and conf range checks before the dt_val[]
write. That covers the converter child path.
The top-level "renesas,miic-switch-portin" value still looks unchecked
after that patch:
if (of_property_read_u32(np, "renesas,miic-switch-portin", &conf) == 0)
dt_val[0] = conf;
Could an out-of-range value there still reach conf_to_string[conf[0]] in
miic_dump_conf()?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260928-miic-validate-dtb-v2-0-1ee3d33748e9%40reliablecontrols.com
next prev parent reply other threads:[~2026-10-01 12:21 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-28 21:19 [PATCH net-next v2 0/3] net: pcs: rzn1-miic: Validate dtb configuration values Kyle Hendry via B4 Relay
2026-09-28 21:19 ` [PATCH net-next v2 1/3] net: pcs: rzn1-miic: Fix port numbering on RZ/T2H Kyle Hendry via B4 Relay
2026-10-01 11:27 ` Lad, Prabhakar
2026-10-01 12:20 ` netdev-bot+sashiko [this message]
2026-09-28 21:19 ` [PATCH net-next v2 2/3] net: pcs: rzn1-miic: Fix miic register initialization loop Kyle Hendry via B4 Relay
2026-10-01 12:21 ` netdev-bot+sashiko
2026-10-01 12:52 ` Lad, Prabhakar
2026-09-28 21:19 ` [PATCH net-next v2 3/3] net: pcs: rzn1-miic: Validate dtb configuration values Kyle Hendry via B4 Relay
2026-10-01 12:21 ` netdev-bot+sashiko
2026-09-28 21:25 ` [PATCH net-next v2 0/3] " netdev-bot+sinfo
2026-09-29 18:13 ` Kyle Hendry
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=179085725981.434549.8679017357220612418@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew@lunn.ch \
--cc=clement.leger@bootlin.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=khendry@reliablecontrols.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
all inboxes | Powered by JetHome®