Commit 140ca9d3 authored by Johan Hovold's avatar Johan Hovold Committed by David S. Miller

net: ethernet: bcmgenet: 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.

Note that we're still leaking any fixed-link PHY registered in the
non-OF probe path.

Fixes: 9abf0c2b ("net: bcmgenet: 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 39f8b0d4
...@@ -627,6 +627,7 @@ static int bcmgenet_mii_bus_init(struct bcmgenet_priv *priv) ...@@ -627,6 +627,7 @@ static int bcmgenet_mii_bus_init(struct bcmgenet_priv *priv)
int bcmgenet_mii_init(struct net_device *dev) int bcmgenet_mii_init(struct net_device *dev)
{ {
struct bcmgenet_priv *priv = netdev_priv(dev); struct bcmgenet_priv *priv = netdev_priv(dev);
struct device_node *dn = priv->pdev->dev.of_node;
int ret; int ret;
ret = bcmgenet_mii_alloc(priv); ret = bcmgenet_mii_alloc(priv);
...@@ -640,6 +641,8 @@ int bcmgenet_mii_init(struct net_device *dev) ...@@ -640,6 +641,8 @@ int bcmgenet_mii_init(struct net_device *dev)
return 0; return 0;
out: out:
if (of_phy_is_fixed_link(dn))
of_phy_deregister_fixed_link(dn);
of_node_put(priv->phy_dn); of_node_put(priv->phy_dn);
mdiobus_unregister(priv->mii_bus); mdiobus_unregister(priv->mii_bus);
mdiobus_free(priv->mii_bus); mdiobus_free(priv->mii_bus);
...@@ -649,7 +652,10 @@ int bcmgenet_mii_init(struct net_device *dev) ...@@ -649,7 +652,10 @@ int bcmgenet_mii_init(struct net_device *dev)
void bcmgenet_mii_exit(struct net_device *dev) void bcmgenet_mii_exit(struct net_device *dev)
{ {
struct bcmgenet_priv *priv = netdev_priv(dev); struct bcmgenet_priv *priv = netdev_priv(dev);
struct device_node *dn = priv->pdev->dev.of_node;
if (of_phy_is_fixed_link(dn))
of_phy_deregister_fixed_link(dn);
of_node_put(priv->phy_dn); of_node_put(priv->phy_dn);
mdiobus_unregister(priv->mii_bus); mdiobus_unregister(priv->mii_bus);
mdiobus_free(priv->mii_bus); mdiobus_free(priv->mii_bus);
......
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