summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Stockhausen2026-02-10 16:16:48 +0000
committerRobert Marko2026-02-13 11:53:47 +0000
commit45fa6e317506b72236ff7583e0bde37077337cda (patch)
treea95e053763367aa57dfdd0d20ff163a6438acc94
parent64d72c74516f330153d69d02ff8693fb299b5b04 (diff)
downloadnbd-45fa6e317506b72236ff7583e0bde37077337cda.tar.gz
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@gmx.de> Link: https://github.com/openwrt/openwrt/pull/21968 Signed-off-by: Robert Marko <robimarko@gmail.com>
-rw-r--r--target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto.c14
1 files 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"))