Skip to contentSkip to conversation

net: mdio: Replaced BUG_ON() with WARN()

PATCH Applied Florian Fainelli 3 participants 3 messages Nov 17, 2021 – Nov 18, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: mdio: Replaced BUG_ON() with WARN()

Killing the kernel because a certain MDIO bus object is not in the desired state at various points in the registration or unregistration paths is excessive and is not helping in troubleshooting or fixing issues. Replace the BUG_ON() with WARN() and print out the MDIO bus name to facilitate debugging.

---
 drivers/net/phy/mdio_bus.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/net/phy/mdio_bus.c +10 -6
index c204067f1890..9b6f2df07211 100644
@@ -176,9 +176,11 @@ static void mdiobus_release(struct device *d)
 {
 	struct mii_bus *bus = to_mii_bus(d);
 
-	BUG_ON(bus->state != MDIOBUS_RELEASED &&
-	       /* for compatibility with error handling in drivers */
-	       bus->state != MDIOBUS_ALLOCATED);
+	WARN(bus->state != MDIOBUS_RELEASED &&
+	     /* for compatibility with error handling in drivers */
+	     bus->state != MDIOBUS_ALLOCATED,
+	     "%s: not in RELEASED or ALLOCATED state\n",
+	     bus->id);
 	kfree(bus);
 }
 
@@ -529,8 +531,9 @@ int __mdiobus_register(struct mii_bus *bus, struct module *owner)
 		bus->parent->of_node->fwnode.flags |=
 					FWNODE_FLAG_NEEDS_CHILD_BOUND_ON_ADD;
 
-	BUG_ON(bus->state != MDIOBUS_ALLOCATED &&
-	       bus->state != MDIOBUS_UNREGISTERED);
+	WARN(bus->state != MDIOBUS_ALLOCATED &&
+	     bus->state != MDIOBUS_UNREGISTERED,
+	     "%s: not in ALLOCATED or UNREGISTERED state\n", bus->id);
 
 	bus->owner = owner;
 	bus->dev.parent = bus->parent;
@@ -658,7 +661,8 @@ void mdiobus_free(struct mii_bus *bus)
 		return;
 	}
 
-	BUG_ON(bus->state != MDIOBUS_UNREGISTERED);
+	WARN(bus->state != MDIOBUS_UNREGISTERED,
+	     "%s: not in UNREGISTERED state\n", bus->id);
 	bus->state = MDIOBUS_RELEASED;
 
 	put_device(&bus->dev);
Signature · 1 line
2.25.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Florian Fainelli

Killing the kernel because a certain MDIO bus object is not in the desired state at various points in the registration or unregistration paths is excessive and is not helping in troubleshooting or fixing issues. Replace the BUG_ON() with WARN() and print out the MDIO bus name to facilitate debugging.

Andrew

#2 lore raw
In reply to Florian Fainelli
This patch was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:

Quoted 9 lines · On Wed, 17 Nov 2021 09:36:29 -0800 you wrote:

Killing the kernel because a certain MDIO bus object is not in the desired state at various points in the registration or unregistration paths is excessive and is not helping in troubleshooting or fixing issues. Replace the BUG_ON() with WARN() and print out the MDIO bus name to facilitate debugging.

[...]

Here is the summary with links:
- [net-next] net: mdio: Replaced BUG_ON() with WARN()

    https://git.kernel.org/netdev/net-next/c/867ae8a7993b

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html