Commit 0807c4ce authored by Johan Hovold's avatar Johan Hovold Committed by David S. Miller

net: ethernet: ucc_geth: 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: 87009814 ("ucc_geth: 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 42c70042
...@@ -3868,9 +3868,8 @@ static int ucc_geth_probe(struct platform_device* ofdev) ...@@ -3868,9 +3868,8 @@ static int ucc_geth_probe(struct platform_device* ofdev)
dev = alloc_etherdev(sizeof(*ugeth)); dev = alloc_etherdev(sizeof(*ugeth));
if (dev == NULL) { if (dev == NULL) {
of_node_put(ug_info->tbi_node); err = -ENOMEM;
of_node_put(ug_info->phy_node); goto err_deregister_fixed_link;
return -ENOMEM;
} }
ugeth = netdev_priv(dev); ugeth = netdev_priv(dev);
...@@ -3907,10 +3906,7 @@ static int ucc_geth_probe(struct platform_device* ofdev) ...@@ -3907,10 +3906,7 @@ static int ucc_geth_probe(struct platform_device* ofdev)
if (netif_msg_probe(ugeth)) if (netif_msg_probe(ugeth))
pr_err("%s: Cannot register net device, aborting\n", pr_err("%s: Cannot register net device, aborting\n",
dev->name); dev->name);
free_netdev(dev); goto err_free_netdev;
of_node_put(ug_info->tbi_node);
of_node_put(ug_info->phy_node);
return err;
} }
mac_addr = of_get_mac_address(np); mac_addr = of_get_mac_address(np);
...@@ -3923,16 +3919,29 @@ static int ucc_geth_probe(struct platform_device* ofdev) ...@@ -3923,16 +3919,29 @@ static int ucc_geth_probe(struct platform_device* ofdev)
ugeth->node = np; ugeth->node = np;
return 0; return 0;
err_free_netdev:
free_netdev(dev);
err_deregister_fixed_link:
if (of_phy_is_fixed_link(np))
of_phy_deregister_fixed_link(np);
of_node_put(ug_info->tbi_node);
of_node_put(ug_info->phy_node);
return err;
} }
static int ucc_geth_remove(struct platform_device* ofdev) static int ucc_geth_remove(struct platform_device* ofdev)
{ {
struct net_device *dev = platform_get_drvdata(ofdev); struct net_device *dev = platform_get_drvdata(ofdev);
struct ucc_geth_private *ugeth = netdev_priv(dev); struct ucc_geth_private *ugeth = netdev_priv(dev);
struct device_node *np = ofdev->dev.of_node;
unregister_netdev(dev); unregister_netdev(dev);
free_netdev(dev); free_netdev(dev);
ucc_geth_memclean(ugeth); ucc_geth_memclean(ugeth);
if (of_phy_is_fixed_link(np))
of_phy_deregister_fixed_link(np);
of_node_put(ugeth->ug_info->tbi_node); of_node_put(ugeth->ug_info->tbi_node);
of_node_put(ugeth->ug_info->phy_node); of_node_put(ugeth->ug_info->phy_node);
......
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