diff options
author | Andrew Lunn <andrew@lunn.ch> | 2018-04-19 03:00:47 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-04-20 17:33:26 +0300 |
commit | 0263ea5cddedd84c111b55d33a8ec94740d1c8d3 (patch) | |
tree | 0260c91048a8ee0ad96fbfd9093cd04ba72db1ab /drivers/net/phy/mdio-boardinfo.c | |
parent | bda73d4ec943c4f7479603a59cad09a07c6c729a (diff) | |
download | linux-0263ea5cddedd84c111b55d33a8ec94740d1c8d3.tar.xz |
net: phy: mdio-boardinfo: Allow recursive mdiobus_register()
mdiobus_register will search for any mdiobus board info registered for
the bus being registered. If found, it will probe devices on the bus.
That device, if for example it is an ethernet switch, may then try to
register an mdio bus. Thus we need to allow recursive calls to
mdiobus_register.
Holding the mdio_board_lock will cause a deadlock during this
recursion. Release the lock and use list_for_each_entry_safe.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/phy/mdio-boardinfo.c')
-rw-r--r-- | drivers/net/phy/mdio-boardinfo.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/net/phy/mdio-boardinfo.c b/drivers/net/phy/mdio-boardinfo.c index 1861f387820d..863496fa5d13 100644 --- a/drivers/net/phy/mdio-boardinfo.c +++ b/drivers/net/phy/mdio-boardinfo.c @@ -30,17 +30,20 @@ void mdiobus_setup_mdiodev_from_board_info(struct mii_bus *bus, struct mdio_board_info *bi)) { struct mdio_board_entry *be; + struct mdio_board_entry *tmp; struct mdio_board_info *bi; int ret; mutex_lock(&mdio_board_lock); - list_for_each_entry(be, &mdio_board_list, list) { + list_for_each_entry_safe(be, tmp, &mdio_board_list, list) { bi = &be->board_info; if (strcmp(bus->id, bi->bus_id)) continue; + mutex_unlock(&mdio_board_lock); ret = cb(bus, bi); + mutex_lock(&mdio_board_lock); if (ret) continue; |