The ixgbe ignores errors returned from mdiobus_register() and leaves
adapter->mii_bus non-NULL and MDIO bus state as MDIOBUS_ALLOCATED.
This triggers a BUG from mdiobus_unregister() during ixgbe_remove() call.
Fixes: 8fa10ef01260 ("ixgbe: register a mdiobus")
Signed-off-by: Ivan Vecera <[email protected]>
---
drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c
index cc4907f9ff02..2fb97967961c 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c
@@ -905,13 +905,12 @@ s32 ixgbe_mii_bus_init(struct ixgbe_hw *hw)
struct pci_dev *pdev = adapter->pdev;
struct device *dev = &adapter->netdev->dev;
struct mii_bus *bus;
+ int err = -ENODEV;
- adapter->mii_bus = devm_mdiobus_alloc(dev);
- if (!adapter->mii_bus)
+ bus = devm_mdiobus_alloc(dev);
+ if (!bus)
return -ENOMEM;
- bus = adapter->mii_bus;
-
switch (hw->device_id) {
/* C3000 SoCs */
case IXGBE_DEV_ID_X550EM_A_KR:
@@ -949,12 +948,15 @@ s32 ixgbe_mii_bus_init(struct ixgbe_hw *hw)
*/
hw->phy.mdio.mode_support = MDIO_SUPPORTS_C45 | MDIO_SUPPORTS_C22;
- return mdiobus_register(bus);
+ err = mdiobus_register(bus);
+ if (!err) {
+ adapter->mii_bus = bus;
+ return 0;
+ }
ixgbe_no_mii_bus:
devm_mdiobus_free(dev, bus);
- adapter->mii_bus = NULL;
- return -ENODEV;
+ return err;
}
/**
--
2.19.2
> -----Original Message-----
> From: Intel-wired-lan [mailto:[email protected]] On
> Behalf Of Ivan Vecera
> Sent: Friday, March 15, 2019 1:45 AM
> To: [email protected]
> Cc: open list <[email protected]>; moderated list:INTEL
> ETHERNET DRIVERS <[email protected]>; David S. Miller
> <[email protected]>
> Subject: [Intel-wired-lan] [PATCH net] ixgbe: fix mdio bus registration
>
> The ixgbe ignores errors returned from mdiobus_register() and leaves
> adapter->mii_bus non-NULL and MDIO bus state as MDIOBUS_ALLOCATED.
> This triggers a BUG from mdiobus_unregister() during ixgbe_remove() call.
>
> Fixes: 8fa10ef01260 ("ixgbe: register a mdiobus")
> Signed-off-by: Ivan Vecera <[email protected]>
> ---
> drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c | 16 +++++++++-------
> 1 file changed, 9 insertions(+), 7 deletions(-)
Tested-by: Andrew Bowers <[email protected]>