Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b9755f03 authored by Johan Hovold's avatar Johan Hovold Committed by David S. Miller
Browse files

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: bb74d9a4 ("fs_enet: use the new fixed PHY helpers")
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 82005b1c
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -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 @@ static int fs_enet_probe(struct platform_device *ofdev)
	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;
}