Skip to content

Commit b9926da

Browse files
calvinjolinuxdavem330
authored andcommitted
net: mii_timestamper: check NULL in unregister_mii_timestamper()
Callers of unregister_mii_timestamper() currently check for NULL value of mii_ts before calling it. Place the NULL check inside unregister_mii_timestamper() and update the callers accordingly. Signed-off-by: Calvin Johnson <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Suggested-by: Andy Shevchenko <[email protected]> Signed-off-by: Ioana Ciornei <[email protected]> Acked-by: Grant Likely <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent cf99686 commit b9926da

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

drivers/net/mdio/of_mdio.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,13 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio,
115115
else
116116
phy = get_phy_device(mdio, addr, is_c45);
117117
if (IS_ERR(phy)) {
118-
if (mii_ts)
119-
unregister_mii_timestamper(mii_ts);
118+
unregister_mii_timestamper(mii_ts);
120119
return PTR_ERR(phy);
121120
}
122121

123122
rc = of_mdiobus_phy_device_register(mdio, phy, child, addr);
124123
if (rc) {
125-
if (mii_ts)
126-
unregister_mii_timestamper(mii_ts);
124+
unregister_mii_timestamper(mii_ts);
127125
phy_device_free(phy);
128126
return rc;
129127
}

drivers/net/phy/mii_timestamper.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ void unregister_mii_timestamper(struct mii_timestamper *mii_ts)
111111
struct mii_timestamping_desc *desc;
112112
struct list_head *this;
113113

114+
if (!mii_ts)
115+
return;
116+
114117
/* mii_timestamper statically registered by the PHY driver won't use the
115118
* register_mii_timestamper() and thus don't have ->device set. Don't
116119
* try to unregister these.

drivers/net/phy/phy_device.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -957,8 +957,7 @@ EXPORT_SYMBOL(phy_device_register);
957957
*/
958958
void phy_device_remove(struct phy_device *phydev)
959959
{
960-
if (phydev->mii_ts)
961-
unregister_mii_timestamper(phydev->mii_ts);
960+
unregister_mii_timestamper(phydev->mii_ts);
962961

963962
device_del(&phydev->mdio.dev);
964963

0 commit comments

Comments
 (0)