Skip to contentSkip to conversation

net: mdio-mux: bcm-iproc: call mdiobus_free() in error path

PATCH In review Jon Mason 3 participants 3 messages May 8, 2017

Subsystems (4)
lore
Share & tools
lore

Jon Mason

author
#0 lore raw

PATCH 1/1 net: mdio-mux: bcm-iproc: call mdiobus_free() in error path

If an error is encountered in mdio_mux_init(), the error path will call mdiobus_free(). Since mdiobus_register() has been called prior to mdio_mux_init(), the bus->state will not be MDIOBUS_UNREGISTERED. This causes a BUG_ON() in mdiobus_free(). To correct this issue, add an error path for mdio_mux_init() which calls mdiobus_unregister() prior to mdiobus_free().

Fixes 98bc865a1ec8 ("net: mdio-mux: Add MDIO mux driver for iProc SoCs")
---
 drivers/net/phy/mdio-mux-bcm-iproc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/phy/mdio-mux-bcm-iproc.c +4 -1
index 0a0412524cec..0a5f62e0efcc 100644
@@ -203,11 +203,14 @@ static int mdio_mux_iproc_probe(struct platform_device *pdev)
 			   &md->mux_handle, md, md->mii_bus);
 	if (rc) {
 		dev_info(md->dev, "mdiomux initialization failed\n");
-		goto out;
+		goto out_register;
 	}
 
 	dev_info(md->dev, "iProc mdiomux registered\n");
 	return 0;
+
+out_register:
+	mdiobus_unregister(bus);
 out:
 	mdiobus_free(bus);
 	return rc;
Signature · 1 line
2.7.4
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Jon Mason

If an error is encountered in mdio_mux_init(), the error path will call mdiobus_free(). Since mdiobus_register() has been called prior to mdio_mux_init(), the bus->state will not be MDIOBUS_UNREGISTERED. This causes a BUG_ON() in mdiobus_free(). To correct this issue, add an error path for mdio_mux_init() which calls mdiobus_unregister() prior to mdiobus_free().

Fixes 98bc865a1ec8 ("net: mdio-mux: Add MDIO mux driver for iProc SoCs")
Signature · 1 line
Florian
maintainer
#2 lore raw
In reply to Jon Mason

From: Jon Mason <[email protected]>
Date: Mon, 8 May 2017 17:48:35 -0400

Quoted 9 lines

If an error is encountered in mdio_mux_init(), the error path will call mdiobus_free(). Since mdiobus_register() has been called prior to mdio_mux_init(), the bus->state will not be MDIOBUS_UNREGISTERED. This causes a BUG_ON() in mdiobus_free(). To correct this issue, add an error path for mdio_mux_init() which calls mdiobus_unregister() prior to mdiobus_free().

Fixes 98bc865a1ec8 ("net: mdio-mux: Add MDIO mux driver for iProc SoCs")

Applied and queued up for -stable.