The reg property identifies the hardware MDIO bus and is used as an index into the per-bus state. However, duplicate bus IDs are currently not rejected explicitly and only fail later during MDIO bus registration due to the duplicate bus ID. Keep track of successfully registered buses and reject a duplicate reg value before allocating another bus. For this use the already existing but currently unused priv->bus[] property. Signed-off-by: Markus Stockhausen --- drivers/net/mdio/mdio-realtek-rtl9300.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/mdio/mdio-realtek-rtl9300.c b/drivers/net/mdio/mdio-realtek-rtl9300.c index de0204d8be48..14fc98949fa3 100644 --- a/drivers/net/mdio/mdio-realtek-rtl9300.c +++ b/drivers/net/mdio/mdio-realtek-rtl9300.c @@ -846,6 +846,9 @@ static int otto_emdio_probe_one(struct device *dev, struct otto_emdio_priv *priv return dev_err_probe(dev, -EINVAL, "illegal (dangling) smi bus number %d\n", mdio_bus); + if (priv->bus[mdio_bus]) + return dev_err_probe(dev, -EINVAL, "duplicated smi bus number %d\n", mdio_bus); + bus = devm_mdiobus_alloc_size(dev, sizeof(*chan)); if (!bus) return -ENOMEM; @@ -869,6 +872,8 @@ static int otto_emdio_probe_one(struct device *dev, struct otto_emdio_priv *priv if (err) return dev_err_probe(dev, err, "cannot register MDIO bus\n"); + priv->bus[mdio_bus] = bus; + return 0; } -- 2.55.0