From: Kyle Hendry via B4 Relay <devnull+khendry.reliablecontrols.com@kernel.org>
To: "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@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Lad Prabhakar" <prabhakar.mahadev-lad.rj@bp.renesas.com>
Cc: linux-renesas-soc@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org,
Kyle Hendry <khendry@reliablecontrols.com>
Subject: [PATCH net-next 2/2] net: pcs: rzn1-miic: Validate dtb configuration values
Date: Fri, 25 Sep 2026 08:12:07 -0700 [thread overview]
Message-ID: <20260925-miic-validate-dtb-v1-2-3a6db9bb75ec@reliablecontrols.com> (raw)
In-Reply-To: <20260925-miic-validate-dtb-v1-0-3a6db9bb75ec@reliablecontrols.com>
From: Kyle Hendry <khendry@reliablecontrols.com>
Bad configuration values from the dtb could result in out of bounds array
access. Verify that parsed values are within range for the SoC and fail the
probe if they are invalid.
Signed-off-by: Kyle Hendry <khendry@reliablecontrols.com>
---
drivers/net/pcs/pcs-rzn1-miic.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/drivers/net/pcs/pcs-rzn1-miic.c b/drivers/net/pcs/pcs-rzn1-miic.c
index 62daaf76e052..30ac2d407005 100644
--- a/drivers/net/pcs/pcs-rzn1-miic.c
+++ b/drivers/net/pcs/pcs-rzn1-miic.c
@@ -695,9 +695,24 @@ 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_PORT_END(miic->of_data)) {
+ dev_err(miic->dev, "Port number out of range: %d\n", port);
+ of_node_put(conv);
+ ret = -EINVAL;
+ goto err;
+ }
+
if (of_property_read_u32(conv, "renesas,miic-input", &conf))
continue;
+ if (conf >= miic->of_data->conf_to_string_count) {
+ dev_err(miic->dev, "Port configuration out of range: %d\n", conf);
+ of_node_put(conv);
+ ret = -EINVAL;
+ goto err;
+ }
+
/* Adjust for 0 based index */
dt_val[port + !miic->of_data->miic_port_start] = conf;
@@ -707,6 +722,7 @@ static int miic_parse_dt(struct miic *miic, u32 *mode_cfg)
}
ret = miic_match_dt_conf(miic, dt_val, mode_cfg);
+err:
kfree(dt_val);
return ret;
--
2.43.0
prev parent reply other threads:[~2026-09-25 15:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-25 15:12 [PATCH net-next 0/2] " Kyle Hendry via B4 Relay
2026-09-25 15:12 ` [PATCH net-next 1/2] net: pcs: rzn1-miic: Make usage of miic_port_max consistent Kyle Hendry via B4 Relay
2026-09-25 16:53 ` Geert Uytterhoeven
2026-09-25 15:12 ` Kyle Hendry via B4 Relay [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=20260925-miic-validate-dtb-v1-2-3a6db9bb75ec@reliablecontrols.com \
--to=devnull+khendry.reliablecontrols.com@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®