From 0fbf80b4c8418e72f12775dc337b518e769d1f36 Mon Sep 17 00:00:00 2001 From: Markus Stockhausen Date: Sun, 22 Mar 2026 15:38:19 +0100 Subject: [PATCH] realtek: mdio: add duplicated port detection Harden the mdio driver probing by checking for duplicate port definitions. Now that the driver has a valid_port mask this is just a simple bit check. This is the same as upstream does. Signed-off-by: Markus Stockhausen Link: https://github.com/openwrt/openwrt/pull/22565 Signed-off-by: Robert Marko --- .../realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto.c b/target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto.c index 2ea24390c4..363974d4f6 100644 --- a/target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto.c +++ b/target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto.c @@ -861,6 +861,10 @@ static int rtmdio_map_ports(struct device *dev) return dev_err_probe(dev, -EINVAL, "%pfwP illegal port number\n", of_fwnode_handle(port)); + if (test_bit(addr, ctrl->valid_ports)) + return dev_err_probe(dev, -EINVAL, "%pfwP duplicated port number\n", + of_fwnode_handle(port)); + if (of_property_read_u32(phy, "reg", &ctrl->smi_addr[addr])) return dev_err_probe(dev, -EINVAL, "%pfwP no phy address\n", of_fwnode_handle(phy));