Thread (6 messages) flat view 6 messages, 3 authors, 8d ago

Re: [PATCH v2 2/2] net: pcs: rzn1-miic: Verify port number from dtb

From: Andrew Lunn <andrew@lunn.ch>
Date: 2026-09-01 16:02:24
Also in: linux-renesas-soc, lkml

On Tue, Sep 01, 2026 at 08:25:14AM -0700, Kyle Hendry via B4 Relay wrote:
quoted hunk ↗ jump to hunk
From: Kyle Hendry <redacted>

Add check to make sure port number is in range before writing
to dt_val array

Signed-off-by: Kyle Hendry <redacted>
---
 drivers/net/pcs/pcs-rzn1-miic.c | 5 +++++
 1 file changed, 5 insertions(+)
diff --git a/drivers/net/pcs/pcs-rzn1-miic.c b/drivers/net/pcs/pcs-rzn1-miic.c
index c50b65d064fa..ebd73ed63896 100644
--- a/drivers/net/pcs/pcs-rzn1-miic.c
+++ b/drivers/net/pcs/pcs-rzn1-miic.c
@@ -692,6 +692,11 @@ 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);
+			continue;
Better to return -EINVAL, so the probe fails and the broken DT blob is
fixed.

    Andrew

---
pw-bot: cr
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help