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: 8fa10ef012 ("ixgbe: register a mdiobus")
Signed-off-by: Ivan Vecera <ivecera@redhat.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
This commit is contained in:
Ivan Vecera 2019-03-15 09:45:15 +01:00 committed by Jeff Kirsher
parent dabb8338be
commit 7ec52b9df7
1 changed files with 9 additions and 7 deletions

View File

@ -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;
}
/**