Commit 5a57a304 authored by Johan Hovold's avatar Johan Hovold Committed by David S. Miller

net: ethernet: marvell: mvneta: 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: 83895bed ("net: mvneta: add support for fixed links")
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
Reviewed-by: default avatarThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0807c4ce
...@@ -4191,6 +4191,8 @@ static int mvneta_probe(struct platform_device *pdev) ...@@ -4191,6 +4191,8 @@ static int mvneta_probe(struct platform_device *pdev)
clk_disable_unprepare(pp->clk); clk_disable_unprepare(pp->clk);
err_put_phy_node: err_put_phy_node:
of_node_put(phy_node); of_node_put(phy_node);
if (of_phy_is_fixed_link(dn))
of_phy_deregister_fixed_link(dn);
err_free_irq: err_free_irq:
irq_dispose_mapping(dev->irq); irq_dispose_mapping(dev->irq);
err_free_netdev: err_free_netdev:
...@@ -4202,6 +4204,7 @@ static int mvneta_probe(struct platform_device *pdev) ...@@ -4202,6 +4204,7 @@ static int mvneta_probe(struct platform_device *pdev)
static int mvneta_remove(struct platform_device *pdev) static int mvneta_remove(struct platform_device *pdev)
{ {
struct net_device *dev = platform_get_drvdata(pdev); struct net_device *dev = platform_get_drvdata(pdev);
struct device_node *dn = pdev->dev.of_node;
struct mvneta_port *pp = netdev_priv(dev); struct mvneta_port *pp = netdev_priv(dev);
unregister_netdev(dev); unregister_netdev(dev);
...@@ -4209,6 +4212,8 @@ static int mvneta_remove(struct platform_device *pdev) ...@@ -4209,6 +4212,8 @@ static int mvneta_remove(struct platform_device *pdev)
clk_disable_unprepare(pp->clk); clk_disable_unprepare(pp->clk);
free_percpu(pp->ports); free_percpu(pp->ports);
free_percpu(pp->stats); free_percpu(pp->stats);
if (of_phy_is_fixed_link(dn))
of_phy_deregister_fixed_link(dn);
irq_dispose_mapping(dev->irq); irq_dispose_mapping(dev->irq);
of_node_put(pp->phy_node); of_node_put(pp->phy_node);
free_netdev(dev); free_netdev(dev);
......
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