All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] net: mdiobus: get rid of a BUG_ON()
@ 2021-05-15 10:01 Dan Carpenter
  2021-05-15 10:15 ` Russell King (Oracle)
  2021-05-15 14:06 ` [PATCH net] " Andrew Lunn
  0 siblings, 2 replies; 5+ messages in thread
From: Dan Carpenter @ 2021-05-15 10:01 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Heiner Kallweit, Russell King, David S. Miller, Jakub Kicinski,
	netdev, linux-kernel, kernel-janitors

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 <linux@armlinux.org.uk>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/net/phy/mdio_bus.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index dadf75ff3ab9..6045ad3def12 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -607,7 +607,8 @@ void mdiobus_unregister(struct mii_bus *bus)
 	struct mdio_device *mdiodev;
 	int i;
 
-	BUG_ON(bus->state != MDIOBUS_REGISTERED);
+	if (WARN_ON_ONCE(bus->state != MDIOBUS_REGISTERED))
+		return;
 	bus->state = MDIOBUS_UNREGISTERED;
 
 	for (i = 0; i < PHY_MAX_ADDR; i++) {
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-05-17 23:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-15 10:01 [PATCH net] net: mdiobus: get rid of a BUG_ON() Dan Carpenter
2021-05-15 10:15 ` Russell King (Oracle)
2021-05-17  9:04   ` [PATCH net v2] " Dan Carpenter
2021-05-17 23:00     ` patchwork-bot+netdevbpf
2021-05-15 14:06 ` [PATCH net] " Andrew Lunn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.