From: Simon Horman <horms@kernel.org>
To: Kyle Hendry <khendry@reliablecontrols.com>
Cc: "Clément Léger" <clement.leger@bootlin.com>,
"Andrew Lunn" <andrew@lunn.ch>,
"Heiner Kallweit" <hkallweit1@gmail.com>,
"Russell King" <linux@armlinux.org.uk>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@kernel.org>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Geert Uytterhoeven" <geert+renesas@glider.be>,
"Magnus Damm" <magnus.damm@gmail.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 net-next v3 2/2] net: pcs: rzn1-miic: Validate dtb configuration values
Date: Fri, 9 Oct 2026 15:26:26 +0100 [thread overview]
Message-ID: <20261009142626.GE83879@horms.kernel.org> (raw)
In-Reply-To: <20261006-miic-validate-dtb-v3-v3-2-68617b3dca5c@reliablecontrols.com>
On Tue, Oct 06, 2026 at 09:48:12AM -0700, Kyle Hendry via B4 Relay wrote:
> From: Kyle Hendry <khendry@reliablecontrols.com>
>
> Bad configuration values from the dtb could result in out of bounds array
> access. Verify parsed values are within range for the SoC and fail the
> probe if invalid.
>
> Signed-off-by: Kyle Hendry <khendry@reliablecontrols.com>
> ---
> drivers/net/pcs/pcs-rzn1-miic.c | 29 +++++++++++++++++++++++++++--
> 1 file changed, 27 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/pcs/pcs-rzn1-miic.c b/drivers/net/pcs/pcs-rzn1-miic.c
> index 31716241b58f..10622eb654d2 100644
> --- a/drivers/net/pcs/pcs-rzn1-miic.c
> +++ b/drivers/net/pcs/pcs-rzn1-miic.c
> @@ -693,16 +693,40 @@ static int miic_parse_dt(struct miic *miic, u32 *mode_cfg)
> memset(dt_val, MIIC_MODCTRL_CONF_NONE,
> sizeof(*dt_val) * miic->of_data->conf_conv_count);
>
> - if (of_property_read_u32(np, "renesas,miic-switch-portin", &conf) == 0)
> - dt_val[0] = conf;
> + if (of_property_read_u32(np, "renesas,miic-switch-portin", &conf) == 0) {
> + if (conf >= miic->of_data->conf_to_string_count) {
> + dev_err(miic->dev, "Port input configuration out of range: %d\n",
> + conf);
> + ret = -EINVAL;
> + goto err;
> + } else {
> + dt_val[0] = conf;
> + }
> + }
Hi Kyle,
Please drop the else arm here, it is unnecessary.
Doing so will move the code into the preferred style
of handling errors conditionally while keeping
the main thread of execution outside (extra) conditions.
(Completely untested, but I mean like this.)
if (of_property_read_u32(np, "renesas,miic-switch-portin", &conf) == 0) {
if (conf >= miic->of_data->conf_to_string_count) {
dev_err(miic->dev, "Port input configuration out of range: %d\n",
conf);
ret = -EINVAL;
goto err;
}
dt_val[0] = conf;
}
With that change, feel free to add:
Reviewed-by: Simon Horman <horms@kernel.org>
--
pw-bot: changes-requested
prev parent reply other threads:[~2026-10-09 14:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-06 16:48 [PATCH net-next v3 0/2] " Kyle Hendry via B4 Relay
2026-10-06 16:48 ` [PATCH net-next v3 1/2] net: pcs: rzn1-miic: Update port numbering for RZ/T2H Kyle Hendry via B4 Relay
2026-10-09 14:22 ` Simon Horman
2026-10-06 16:48 ` [PATCH net-next v3 2/2] net: pcs: rzn1-miic: Validate dtb configuration values Kyle Hendry via B4 Relay
2026-10-09 14:26 ` Simon Horman [this message]
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=20261009142626.GE83879@horms.kernel.org \
--to=horms@kernel.org \
--cc=andrew@lunn.ch \
--cc=clement.leger@bootlin.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=geert+renesas@glider.be \
--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=magnus.damm@gmail.com \
--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®