Commit 7ec52b9d authored by Ivan Vecera's avatar Ivan Vecera Committed by Jeff Kirsher

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: 8fa10ef0 ("ixgbe: register a mdiobus")
Signed-off-by: default avatarIvan Vecera <ivecera@redhat.com>
Tested-by: default avatarAndrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent dabb8338
......@@ -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;
}
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment