]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
realtek: mdio: harden phy address check
authorMarkus Stockhausen <markus.stockhausen@gmx.de>
Fri, 1 May 2026 17:21:10 +0000 (19:21 +0200)
committerRobert Marko <robimarko@gmail.com>
Wed, 6 May 2026 08:52:40 +0000 (10:52 +0200)
As of now RTL839x devices have never more than 32 devices on one
mdio bus. Harden the phy address check during probing.

Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
Link: https://github.com/openwrt/openwrt/pull/23186
Signed-off-by: Robert Marko <robimarko@gmail.com>
target/linux/realtek/files-6.18/drivers/net/mdio/mdio-realtek-otto.c

index 7e5a7a79c851b0860d1159a16abb9039e36f4a8d..37b6a95ae9cb4a3576c2872386da4403c8203f99 100644 (file)
@@ -916,8 +916,7 @@ static int rtmdio_map_ports(struct device *dev)
                        return dev_err_probe(dev, -EINVAL, "%pfwP no phy address\n",
                                             of_fwnode_handle(phy));
 
-               /* relaxed check as RTL839x uses MDIO addresses 0..51 */
-               if (smi_addr >= ctrl->cfg->num_phys)
+               if (smi_addr >= PHY_MAX_ADDR)
                        return dev_err_probe(dev, -EINVAL, "%pfwP illegal phy address\n",
                                             of_fwnode_handle(phy));