OSDN Git Service

net: mii_timestamper: check NULL in unregister_mii_timestamper()
authorCalvin Johnson <calvin.johnson@oss.nxp.com>
Fri, 11 Jun 2021 10:53:53 +0000 (13:53 +0300)
committerDavid S. Miller <davem@davemloft.net>
Fri, 11 Jun 2021 20:08:52 +0000 (13:08 -0700)
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>
drivers/net/mdio/of_mdio.c
drivers/net/phy/mii_timestamper.c
drivers/net/phy/phy_device.c

index 29f121c..d73c057 100644 (file)
@@ -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;
        }
index b71b745..51ae059 100644 (file)
@@ -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.
index f7472a0..8573430 100644 (file)
@@ -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);