netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: netdev@vger.kernel.org
Cc: Claudiu Manoil <claudiu.manoil@freescale.com>,
	kernel@pengutronix.de, Florian Fainelli <f.fainelli@gmail.com>,
	Fabio Estevam <fabio.estevam@freescale.com>
Subject: [PATCH] net: gianfar: fix reference counting for phy_node
Date: Thu,  7 Aug 2014 21:35:31 +0200	[thread overview]
Message-ID: <1407440131-15517-1-git-send-email-u.kleine-koenig@pengutronix.de> (raw)

The line before the changed if condition is:

	priv->phy_node = of_parse_phandle(np, "phy-handle", 0);

. If this call succeeds priv->phy_node must not be overwritten in the if
block; otherwise the reference to the node returned by of_parse_phandle
is lost. So add a check that the if block isn't executed in this case.

Furthermore in the fixed phy case no reference is aquired for phy_node
resulting in an of_node_put without holding a reference. To fix that,
get a reference on the MAC dt node.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/net/ethernet/freescale/gianfar.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
index 6b0c4775cd0d..adc7c718c4bc 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -897,7 +897,7 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
 		if (err)
 			goto err_grp_init;
 
-		priv->phy_node = np;
+		priv->phy_node = of_node_get(np);
 	}
 
 	/* Find the TBI PHY.  If it's not there, we don't support SGMII */
-- 
2.0.1

             reply	other threads:[~2014-08-07 19:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-07 19:35 Uwe Kleine-König [this message]
2014-08-07 19:41 ` [PATCH v2] net: gianfar: fix reference counting for phy_node Uwe Kleine-König
2014-08-07 20:01   ` [PATCH v3] " Uwe Kleine-König
2014-08-07 20:17     ` [PATCH v4] " Uwe Kleine-König
2014-08-07 23:06       ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1407440131-15517-1-git-send-email-u.kleine-koenig@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=claudiu.manoil@freescale.com \
    --cc=f.fainelli@gmail.com \
    --cc=fabio.estevam@freescale.com \
    --cc=kernel@pengutronix.de \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).