Commit 82005b1c authored by Johan Hovold's avatar Johan Hovold Committed by David S. Miller

net: ethernet: fec: fix fixed-link phydev leaks

Make sure to deregister and free any fixed-link PHY registered using
of_phy_register_fixed_link() on probe errors and on driver unbind.

Fixes: 407066f8 ("net: fec: Support phys probed from devicetree and
fixed-link")
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 140ca9d3
...@@ -3475,6 +3475,8 @@ fec_probe(struct platform_device *pdev) ...@@ -3475,6 +3475,8 @@ fec_probe(struct platform_device *pdev)
failed_clk_ipg: failed_clk_ipg:
fec_enet_clk_enable(ndev, false); fec_enet_clk_enable(ndev, false);
failed_clk: failed_clk:
if (of_phy_is_fixed_link(np))
of_phy_deregister_fixed_link(np);
failed_phy: failed_phy:
of_node_put(phy_node); of_node_put(phy_node);
failed_ioremap: failed_ioremap:
...@@ -3488,6 +3490,7 @@ fec_drv_remove(struct platform_device *pdev) ...@@ -3488,6 +3490,7 @@ fec_drv_remove(struct platform_device *pdev)
{ {
struct net_device *ndev = platform_get_drvdata(pdev); struct net_device *ndev = platform_get_drvdata(pdev);
struct fec_enet_private *fep = netdev_priv(ndev); struct fec_enet_private *fep = netdev_priv(ndev);
struct device_node *np = pdev->dev.of_node;
cancel_work_sync(&fep->tx_timeout_work); cancel_work_sync(&fep->tx_timeout_work);
fec_ptp_stop(pdev); fec_ptp_stop(pdev);
...@@ -3495,6 +3498,8 @@ fec_drv_remove(struct platform_device *pdev) ...@@ -3495,6 +3498,8 @@ fec_drv_remove(struct platform_device *pdev)
fec_enet_mii_remove(fep); fec_enet_mii_remove(fep);
if (fep->reg_phy) if (fep->reg_phy)
regulator_disable(fep->reg_phy); regulator_disable(fep->reg_phy);
if (of_phy_is_fixed_link(np))
of_phy_deregister_fixed_link(np);
of_node_put(fep->phy_node); of_node_put(fep->phy_node);
free_netdev(ndev); free_netdev(ndev);
......
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