Commit b9926da0 authored by Calvin Johnson's avatar Calvin Johnson Committed by David S. Miller

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: default avatarCalvin Johnson <calvin.johnson@oss.nxp.com>
Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Suggested-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: default avatarIoana Ciornei <ioana.ciornei@nxp.com>
Acked-by: default avatarGrant Likely <grant.likely@arm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cf996860
......@@ -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;
}
......
......@@ -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.
......
......@@ -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);
......
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