summaryrefslogtreecommitdiffstats
path: root/drivers/of
diff options
context:
space:
mode:
authorMichael Walle <michael@walle.cc>2020-01-30 18:44:50 +0100
committerJakub Kicinski <kuba@kernel.org>2020-01-31 07:46:11 -0800
commit0e0daf6ac3be70608569262246f6dc33cb3f45fe (patch)
treeeb25c5a6b7e4105c3ff95af5d584b189d6697d0d /drivers/of
parent9f68e3655aae6d49d6ba05dd263f99f33c2567af (diff)
downloadblackbird-op-linux-0e0daf6ac3be70608569262246f6dc33cb3f45fe.tar.gz
blackbird-op-linux-0e0daf6ac3be70608569262246f6dc33cb3f45fe.zip
net: mdio: of: fix potential NULL pointer derefernce
of_find_mii_timestamper() returns NULL if no timestamper is found. Therefore, guard the unregister_mii_timestamper() calls. Fixes: 1dca22b18421 ("net: mdio: of: Register discovered MII time stampers.") Signed-off-by: Michael Walle <michael@walle.cc> Acked-by: Richard Cochran <richardcochran@gmail.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'drivers/of')
-rw-r--r--drivers/of/of_mdio.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
index f5c2a5487761..db0ed5879803 100644
--- a/drivers/of/of_mdio.c
+++ b/drivers/of/of_mdio.c
@@ -81,13 +81,15 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio,
else
phy = get_phy_device(mdio, addr, is_c45);
if (IS_ERR(phy)) {
- unregister_mii_timestamper(mii_ts);
+ if (mii_ts)
+ unregister_mii_timestamper(mii_ts);
return PTR_ERR(phy);
}
rc = of_irq_get(child, 0);
if (rc == -EPROBE_DEFER) {
- unregister_mii_timestamper(mii_ts);
+ if (mii_ts)
+ unregister_mii_timestamper(mii_ts);
phy_device_free(phy);
return rc;
}
@@ -116,7 +118,8 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio,
* register it */
rc = phy_device_register(phy);
if (rc) {
- unregister_mii_timestamper(mii_ts);
+ if (mii_ts)
+ unregister_mii_timestamper(mii_ts);
phy_device_free(phy);
of_node_put(child);
return rc;
OpenPOWER on IntegriCloud