From 41e9574297a785e32b79618c75eb08ff73bbe448 Mon Sep 17 00:00:00 2001 From: Markus Stockhausen Date: Fri, 1 May 2026 19:21:10 +0200 Subject: [PATCH] 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 Link: https://github.com/openwrt/openwrt/pull/23186 Signed-off-by: Robert Marko --- .../realtek/files-6.18/drivers/net/mdio/mdio-realtek-otto.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/target/linux/realtek/files-6.18/drivers/net/mdio/mdio-realtek-otto.c b/target/linux/realtek/files-6.18/drivers/net/mdio/mdio-realtek-otto.c index 7e5a7a79c85..37b6a95ae9c 100644 --- a/target/linux/realtek/files-6.18/drivers/net/mdio/mdio-realtek-otto.c +++ b/target/linux/realtek/files-6.18/drivers/net/mdio/mdio-realtek-otto.c @@ -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));