Skip to content

Commit 0263ea5

Browse files
lunndavem330
authored andcommitted
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>
1 parent bda73d4 commit 0263ea5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/net/phy/mdio-boardinfo.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,20 @@ void mdiobus_setup_mdiodev_from_board_info(struct mii_bus *bus,
3030
struct mdio_board_info *bi))
3131
{
3232
struct mdio_board_entry *be;
33+
struct mdio_board_entry *tmp;
3334
struct mdio_board_info *bi;
3435
int ret;
3536

3637
mutex_lock(&mdio_board_lock);
37-
list_for_each_entry(be, &mdio_board_list, list) {
38+
list_for_each_entry_safe(be, tmp, &mdio_board_list, list) {
3839
bi = &be->board_info;
3940

4041
if (strcmp(bus->id, bi->bus_id))
4142
continue;
4243

44+
mutex_unlock(&mdio_board_lock);
4345
ret = cb(bus, bi);
46+
mutex_lock(&mdio_board_lock);
4447
if (ret)
4548
continue;
4649

0 commit comments

Comments
 (0)