]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
realtek: mdio: harden rtmdio_probe_one()
authorMarkus Stockhausen <markus.stockhausen@gmx.de>
Sun, 3 May 2026 16:34:38 +0000 (18:34 +0200)
committerRobert Marko <robimarko@gmail.com>
Tue, 5 May 2026 11:12:17 +0000 (13:12 +0200)
rtmdio_probe_one() should be only called by rtmdio_probe() after it
has validated the dts input. Nevertheless be defensive and add
another consistency check.

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

index 8bd674810b4c7f7078b098e7570d6ffe23162976..6be60c9b42b84e12b6c3d9992ace74f4f7b91a51 100644 (file)
@@ -945,7 +945,9 @@ static int rtmdio_probe_one(struct device *dev, struct rtmdio_ctrl *ctrl,
 
        ret = fwnode_property_read_u32(node, "reg", &smi_bus);
        if (ret)
-               return ret;
+               return dev_err_probe(dev, ret, "%pfwP missing reg property for MDIO bus\n", node);
+       if (smi_bus >= ctrl->cfg->num_busses)
+               return dev_err_probe(dev, -EINVAL, "%pfwP wrong bus index %d\n", node, smi_bus);
 
        bus = devm_mdiobus_alloc_size(dev, sizeof(*chan));
        if (!bus)