Skip to content

Commit

Permalink
net: mii_timestamper: check NULL in unregister_mii_timestamper()
Browse files Browse the repository at this point in the history
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 <calvin.johnson@oss.nxp.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Acked-by: Grant Likely <grant.likely@arm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Calvin Johnson authored and David S. Miller committed Jun 11, 2021
1 parent cf99686 commit b9926da
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 2 additions & 4 deletions drivers/net/mdio/of_mdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,13 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio,
else
phy = get_phy_device(mdio, addr, is_c45);
if (IS_ERR(phy)) {
if (mii_ts)
unregister_mii_timestamper(mii_ts);
unregister_mii_timestamper(mii_ts);
return PTR_ERR(phy);
}

rc = of_mdiobus_phy_device_register(mdio, phy, child, addr);
if (rc) {
if (mii_ts)
unregister_mii_timestamper(mii_ts);
unregister_mii_timestamper(mii_ts);
phy_device_free(phy);
return rc;
}
Expand Down
3 changes: 3 additions & 0 deletions drivers/net/phy/mii_timestamper.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ void unregister_mii_timestamper(struct mii_timestamper *mii_ts)
struct mii_timestamping_desc *desc;
struct list_head *this;

if (!mii_ts)
return;

/* mii_timestamper statically registered by the PHY driver won't use the
* register_mii_timestamper() and thus don't have ->device set. Don't
* try to unregister these.
Expand Down
3 changes: 1 addition & 2 deletions drivers/net/phy/phy_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -957,8 +957,7 @@ EXPORT_SYMBOL(phy_device_register);
*/
void phy_device_remove(struct phy_device *phydev)
{
if (phydev->mii_ts)
unregister_mii_timestamper(phydev->mii_ts);
unregister_mii_timestamper(phydev->mii_ts);

device_del(&phydev->mdio.dev);

Expand Down

0 comments on commit b9926da

Please sign in to comment.