]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
realtek: mdio: add duplicated port detection
authorMarkus Stockhausen <markus.stockhausen@gmx.de>
Sun, 22 Mar 2026 14:38:19 +0000 (15:38 +0100)
committerRobert Marko <robimarko@gmail.com>
Mon, 23 Mar 2026 10:18:03 +0000 (11:18 +0100)
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 <markus.stockhausen@gmx.de>
Link: https://github.com/openwrt/openwrt/pull/22565
Signed-off-by: Robert Marko <robimarko@gmail.com>
target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto.c

index 2ea24390c42df6d4aef55be881a86a6257d4a557..363974d4f61ea83fdde3b20e07a19604479f7934 100644 (file)
@@ -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));