Commit 0e0daf6a authored by Michael Walle's avatar Michael Walle Committed by Jakub Kicinski

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: 1dca22b1 ("net: mdio: of: Register discovered MII time stampers.")
Signed-off-by: default avatarMichael Walle <michael@walle.cc>
Acked-by: default avatarRichard Cochran <richardcochran@gmail.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 9f68e365
......@@ -81,12 +81,14 @@ 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);
return PTR_ERR(phy);
}
rc = of_irq_get(child, 0);
if (rc == -EPROBE_DEFER) {
if (mii_ts)
unregister_mii_timestamper(mii_ts);
phy_device_free(phy);
return rc;
......@@ -116,6 +118,7 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio,
* register it */
rc = phy_device_register(phy);
if (rc) {
if (mii_ts)
unregister_mii_timestamper(mii_ts);
phy_device_free(phy);
of_node_put(child);
......
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