Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <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>

authored by

Calvin Johnson and committed by
David S. Miller
b9926da0 cf996860

+6 -6
+2 -4
drivers/net/mdio/of_mdio.c
··· 115 115 else 116 116 phy = get_phy_device(mdio, addr, is_c45); 117 117 if (IS_ERR(phy)) { 118 - if (mii_ts) 119 - unregister_mii_timestamper(mii_ts); 118 + unregister_mii_timestamper(mii_ts); 120 119 return PTR_ERR(phy); 121 120 } 122 121 123 122 rc = of_mdiobus_phy_device_register(mdio, phy, child, addr); 124 123 if (rc) { 125 - if (mii_ts) 126 - unregister_mii_timestamper(mii_ts); 124 + unregister_mii_timestamper(mii_ts); 127 125 phy_device_free(phy); 128 126 return rc; 129 127 }
+3
drivers/net/phy/mii_timestamper.c
··· 111 111 struct mii_timestamping_desc *desc; 112 112 struct list_head *this; 113 113 114 + if (!mii_ts) 115 + return; 116 + 114 117 /* mii_timestamper statically registered by the PHY driver won't use the 115 118 * register_mii_timestamper() and thus don't have ->device set. Don't 116 119 * try to unregister these.
+1 -2
drivers/net/phy/phy_device.c
··· 957 957 */ 958 958 void phy_device_remove(struct phy_device *phydev) 959 959 { 960 - if (phydev->mii_ts) 961 - unregister_mii_timestamper(phydev->mii_ts); 960 + unregister_mii_timestamper(phydev->mii_ts); 962 961 963 962 device_del(&phydev->mdio.dev); 964 963