Skip to content

Commit

Permalink
net: mdiobus: get rid of a BUG_ON()
Browse files Browse the repository at this point in the history
[ Upstream commit 1dde47a ]

We spotted a bug recently during a review where a driver was
unregistering a bus that wasn't registered, which would trigger this
BUG_ON().  Let's handle that situation more gracefully, and just print
a warning and return.

Reported-by: Russell King (Oracle) <[email protected]>
Signed-off-by: Dan Carpenter <[email protected]>
Reviewed-by: Russell King (Oracle) <[email protected]>
Reviewed-by: Andrew Lunn <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
Signed-off-by: Lee Jones <[email protected]>
Change-Id: I0faa737c71f6ba758c8f645af42e210bec380386
  • Loading branch information
Dan Carpenter authored and lag-google committed Aug 6, 2021
1 parent f08d08a commit 7aeb97c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/net/phy/mdio_bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,8 @@ void mdiobus_unregister(struct mii_bus *bus)
{
int i;

BUG_ON(bus->state != MDIOBUS_REGISTERED);
if (WARN_ON_ONCE(bus->state != MDIOBUS_REGISTERED))
return;
bus->state = MDIOBUS_UNREGISTERED;

device_del(&bus->dev);
Expand Down

0 comments on commit 7aeb97c

Please sign in to comment.