[openwrt/openwrt] realtek: mdio: harden mdio probing
LEDE Commits
lede-commits at lists.infradead.org
Fri Feb 13 03:53:55 PST 2026
robimarko pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/45fa6e317506b72236ff7583e0bde37077337cda
commit 45fa6e317506b72236ff7583e0bde37077337cda
Author: Markus Stockhausen <markus.stockhausen at gmx.de>
AuthorDate: Tue Feb 10 17:16:48 2026 +0100
realtek: mdio: harden mdio probing
Do better error checks during bus probing. Give meaningful return codes
in case of invalid DTS data (EINVAL instead of ENODEV). Decrease node
reference in case of errors.
Signed-off-by: Markus Stockhausen <markus.stockhausen at gmx.de>
Link: https://github.com/openwrt/openwrt/pull/21968
Signed-off-by: Robert Marko <robimarko at gmail.com>
---
.../files-6.12/drivers/net/mdio/mdio-realtek-otto.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
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 bb61b9d48c..628de4790a 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
@@ -913,18 +913,20 @@ static int rtmdio_probe(struct platform_device *pdev)
if (of_property_read_u32(dn, "reg", &addr))
continue;
- if (addr >= ctrl->cfg->cpu_port) {
- pr_err("%s: illegal port number %d\n", __func__, addr);
- return -ENODEV;
+ if (addr < 0 || addr >= ctrl->cfg->cpu_port) {
+ dev_err(dev, "illegal port number %d\n", addr);
+ of_node_put(dn);
+ return -EINVAL;
}
of_property_read_u32(dn->parent, "reg", &ctrl->smi_bus[addr]);
if (of_property_read_u32(dn, "realtek,smi-address", &ctrl->smi_addr[addr]))
ctrl->smi_addr[addr] = addr;
- if (ctrl->smi_bus[addr] >= RTMDIO_MAX_SMI_BUS) {
- pr_err("%s: illegal SMI bus number %d\n", __func__, ctrl->smi_bus[addr]);
- return -ENODEV;
+ if (ctrl->smi_bus[addr] < 0 || ctrl->smi_bus[addr] >= RTMDIO_MAX_SMI_BUS) {
+ dev_err(dev, "illegal SMI bus number %d\n", ctrl->smi_bus[addr]);
+ of_node_put(dn);
+ return -EINVAL;
}
if (of_device_is_compatible(dn, "ethernet-phy-ieee802.3-c45"))
More information about the lede-commits
mailing list