net: ethernet: fs_enet: 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: bb74d9a4a8
("fs_enet: use the new fixed PHY helpers")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
82005b1c19
commit
b9755f0372
@ -980,7 +980,7 @@ static int fs_enet_probe(struct platform_device *ofdev)
|
||||
err = clk_prepare_enable(clk);
|
||||
if (err) {
|
||||
ret = err;
|
||||
goto out_free_fpi;
|
||||
goto out_deregister_fixed_link;
|
||||
}
|
||||
fpi->clk_per = clk;
|
||||
}
|
||||
@ -1061,6 +1061,9 @@ out_put:
|
||||
of_node_put(fpi->phy_node);
|
||||
if (fpi->clk_per)
|
||||
clk_disable_unprepare(fpi->clk_per);
|
||||
out_deregister_fixed_link:
|
||||
if (of_phy_is_fixed_link(ofdev->dev.of_node))
|
||||
of_phy_deregister_fixed_link(ofdev->dev.of_node);
|
||||
out_free_fpi:
|
||||
kfree(fpi);
|
||||
return ret;
|
||||
@ -1079,6 +1082,8 @@ static int fs_enet_remove(struct platform_device *ofdev)
|
||||
of_node_put(fep->fpi->phy_node);
|
||||
if (fep->fpi->clk_per)
|
||||
clk_disable_unprepare(fep->fpi->clk_per);
|
||||
if (of_phy_is_fixed_link(ofdev->dev.of_node))
|
||||
of_phy_deregister_fixed_link(ofdev->dev.of_node);
|
||||
free_netdev(ndev);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user