aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2014-08-07 16:53:40 -0400
committerDavid S. Miller <davem@davemloft.net>2014-08-07 19:02:58 -0400
commit9518259ffc87328676bf2c2041348c5181856f96 (patch)
tree7b8c4745c68b3f65086f014a1772fdf6b4331312 /drivers/net/ethernet
parentabac0d3f80ec8cbec5589bb2cebec188bf5f03e0 (diff)
net: bcmgenet: fix reference counting for phy node
For the fixed phy setup make sure to not overwrite a valid value of phy_dn (that is holding a reference to a phy-handle) and also acquire a reference to the MAC node to consistently return with the phy_dn pointer holding a reference. Also add the corresponding of_node_put in the error path and the remove function. Fixes: 9abf0c2b717a ("net: bcmgenet: use the new fixed PHY helpers") Fixes: aa09677cba42 ("net: bcmgenet: add MDIO routines") Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r--drivers/net/ethernet/broadcom/genet/bcmmii.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/ethernet/broadcom/genet/bcmmii.c
index 18961613d385..b56f1bbb17bf 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmmii.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c
@@ -303,12 +303,12 @@ static int bcmgenet_mii_probe(struct net_device *dev)
303 /* In the case of a fixed PHY, the DT node associated 303 /* In the case of a fixed PHY, the DT node associated
304 * to the PHY is the Ethernet MAC DT node. 304 * to the PHY is the Ethernet MAC DT node.
305 */ 305 */
306 if (of_phy_is_fixed_link(dn)) { 306 if (!priv->phy_dn && of_phy_is_fixed_link(dn)) {
307 ret = of_phy_register_fixed_link(dn); 307 ret = of_phy_register_fixed_link(dn);
308 if (ret) 308 if (ret)
309 return ret; 309 return ret;
310 310
311 priv->phy_dn = dn; 311 priv->phy_dn = of_node_get(dn);
312 } 312 }
313 313
314 phydev = of_phy_connect(dev, priv->phy_dn, bcmgenet_mii_setup, 0, 314 phydev = of_phy_connect(dev, priv->phy_dn, bcmgenet_mii_setup, 0,
@@ -444,6 +444,7 @@ int bcmgenet_mii_init(struct net_device *dev)
444 return 0; 444 return 0;
445 445
446out: 446out:
447 of_node_put(priv->phy_dn);
447 mdiobus_unregister(priv->mii_bus); 448 mdiobus_unregister(priv->mii_bus);
448out_free: 449out_free:
449 kfree(priv->mii_bus->irq); 450 kfree(priv->mii_bus->irq);
@@ -455,6 +456,7 @@ void bcmgenet_mii_exit(struct net_device *dev)
455{ 456{
456 struct bcmgenet_priv *priv = netdev_priv(dev); 457 struct bcmgenet_priv *priv = netdev_priv(dev);
457 458
459 of_node_put(priv->phy_dn);
458 mdiobus_unregister(priv->mii_bus); 460 mdiobus_unregister(priv->mii_bus);
459 kfree(priv->mii_bus->irq); 461 kfree(priv->mii_bus->irq);
460 mdiobus_free(priv->mii_bus); 462 mdiobus_free(priv->mii_bus);