aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/phy/phy_device.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/phy/phy_device.c')
-rw-r--r--drivers/net/phy/phy_device.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 92b08383cafa..0d8f4d3847f6 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -920,6 +920,11 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
920 return -EIO; 920 return -EIO;
921 } 921 }
922 922
923 if (!try_module_get(d->driver->owner)) {
924 dev_err(&dev->dev, "failed to get the device driver module\n");
925 return -EIO;
926 }
927
923 get_device(d); 928 get_device(d);
924 929
925 /* Assume that if there is no driver, that it doesn't 930 /* Assume that if there is no driver, that it doesn't
@@ -977,6 +982,7 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
977error: 982error:
978 phy_detach(phydev); 983 phy_detach(phydev);
979 put_device(d); 984 put_device(d);
985 module_put(d->driver->owner);
980 if (ndev_owner != bus->owner) 986 if (ndev_owner != bus->owner)
981 module_put(bus->owner); 987 module_put(bus->owner);
982 return err; 988 return err;
@@ -1059,6 +1065,7 @@ void phy_detach(struct phy_device *phydev)
1059 bus = phydev->mdio.bus; 1065 bus = phydev->mdio.bus;
1060 1066
1061 put_device(&phydev->mdio.dev); 1067 put_device(&phydev->mdio.dev);
1068 module_put(phydev->mdio.dev.driver->owner);
1062 if (ndev_owner != bus->owner) 1069 if (ndev_owner != bus->owner)
1063 module_put(bus->owner); 1070 module_put(bus->owner);
1064} 1071}