realtek: mdio: harden phy address check

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>
This commit is contained in:
Markus Stockhausen
2026-05-01 19:21:10 +02:00
committed by Robert Marko
parent 593df57731
commit 41e9574297
@@ -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));