* [PATCH] net: bcmgenet: fix reference counting for phy node
@ 2014-08-07 20:53 Uwe Kleine-König
2014-08-07 23:07 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Uwe Kleine-König @ 2014-08-07 20:53 UTC (permalink / raw)
To: Florian Fainelli; +Cc: netdev
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>
---
drivers/net/ethernet/broadcom/genet/bcmmii.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/ethernet/broadcom/genet/bcmmii.c
index add8d8596084..cdb28dd7d19d 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmmii.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c
@@ -311,12 +311,12 @@ static int bcmgenet_mii_probe(struct net_device *dev)
/* In the case of a fixed PHY, the DT node associated
* to the PHY is the Ethernet MAC DT node.
*/
- if (of_phy_is_fixed_link(dn)) {
+ if (!priv->phy_dn && of_phy_is_fixed_link(dn)) {
ret = of_phy_register_fixed_link(dn);
if (ret)
return ret;
- priv->phy_dn = dn;
+ priv->phy_dn = of_node_get(dn);
}
phydev = of_phy_connect(dev, priv->phy_dn, bcmgenet_mii_setup, 0,
@@ -452,6 +452,7 @@ int bcmgenet_mii_init(struct net_device *dev)
return 0;
out:
+ of_node_put(priv->phy_dn);
mdiobus_unregister(priv->mii_bus);
out_free:
kfree(priv->mii_bus->irq);
@@ -463,6 +464,7 @@ void bcmgenet_mii_exit(struct net_device *dev)
{
struct bcmgenet_priv *priv = netdev_priv(dev);
+ of_node_put(priv->phy_dn);
mdiobus_unregister(priv->mii_bus);
kfree(priv->mii_bus->irq);
mdiobus_free(priv->mii_bus);
--
2.0.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] net: bcmgenet: fix reference counting for phy node
2014-08-07 20:53 [PATCH] net: bcmgenet: fix reference counting for phy node Uwe Kleine-König
@ 2014-08-07 23:07 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2014-08-07 23:07 UTC (permalink / raw)
To: u.kleine-koenig; +Cc: f.fainelli, netdev
From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Date: Thu, 7 Aug 2014 22:53:40 +0200
> 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>
Applied.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-08-07 23:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-07 20:53 [PATCH] net: bcmgenet: fix reference counting for phy node Uwe Kleine-König
2014-08-07 23:07 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).