--- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -616,7 +616,9 @@ struct phy_device *phy_device_create(str if (c45_ids) dev->c45_ids = *c45_ids; dev->irq = bus->irq[addr]; + dev_set_name(&mdiodev->dev, PHY_ID_FMT, bus->id, addr); + device_initialize(&mdiodev->dev); dev->state = PHY_DOWN; @@ -650,10 +652,8 @@ struct phy_device *phy_device_create(str ret = phy_request_driver_module(dev, phy_id); } - if (!ret) { - device_initialize(&mdiodev->dev); - } else { - kfree(dev); + if (ret) { + put_device(&mdiodev->dev); dev = ERR_PTR(ret); }