netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Chen <peter.chen@nxp.com>
To: <davem@davemloft.net>
Cc: <netdev@vger.kernel.org>, <vbridger@opensource.altera.com>,
	<isubramanian@apm.com>, <kchudgar@apm.com>,
	<yisen.zhuang@huawei.com>, <salil.mehta@huawei.com>,
	<thomas.petazzoni@free-electrons.com>,
	<sergei.shtylyov@cogentembedded.com>, <peppe.cavallaro@st.com>,
	<alexandre.torgue@st.com>, <mugunthanvnm@ti.com>,
	<tremyfr@gmail.com>, <wxt@rock-chips.com>, <arnd@arndb.de>,
	<david.daney@cavium.com>, <huangdaode@hisilicon.com>,
	<jszhang@marvell.com>, Peter Chen <peter.chen@nxp.com>
Subject: [PATCH v2 14/15] ethernet: stmicro: stmmac: add missing of_node_put after calling of_parse_phandle
Date: Mon, 1 Aug 2016 15:02:42 +0800	[thread overview]
Message-ID: <1470034963-30506-15-git-send-email-peter.chen@nxp.com> (raw)
In-Reply-To: <1470034963-30506-1-git-send-email-peter.chen@nxp.com>

of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

This commit fixes both local (in stmmac_axi_setup) and global
(plat->phy_node) device_node for this issue, and using the
correct device node when tries to put node at stmmac_probe_config_dt
for error path.

Signed-off-by: Peter Chen <peter.chen@nxp.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c     | 1 +
 drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 7 +++++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index c23ccab..4c8c60a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -3397,6 +3397,7 @@ int stmmac_dvr_remove(struct device *dev)
 	stmmac_set_mac(priv->ioaddr, false);
 	netif_carrier_off(ndev);
 	unregister_netdev(ndev);
+	of_node_put(priv->plat->phy_node);
 	if (priv->stmmac_rst)
 		reset_control_assert(priv->stmmac_rst);
 	clk_disable_unprepare(priv->pclk);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index f7dfc0a..756bb54 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -113,8 +113,10 @@ static struct stmmac_axi *stmmac_axi_setup(struct platform_device *pdev)
 		return NULL;
 
 	axi = kzalloc(sizeof(*axi), GFP_KERNEL);
-	if (!axi)
+	if (!axi) {
+		of_node_put(np);
 		return ERR_PTR(-ENOMEM);
+	}
 
 	axi->axi_lpi_en = of_property_read_bool(np, "snps,lpi_en");
 	axi->axi_xit_frm = of_property_read_bool(np, "snps,xit_frm");
@@ -127,6 +129,7 @@ static struct stmmac_axi *stmmac_axi_setup(struct platform_device *pdev)
 	of_property_read_u32(np, "snps,wr_osr_lmt", &axi->axi_wr_osr_lmt);
 	of_property_read_u32(np, "snps,rd_osr_lmt", &axi->axi_rd_osr_lmt);
 	of_property_read_u32_array(np, "snps,blen", axi->axi_blen, AXI_BLEN);
+	of_node_put(np);
 
 	return axi;
 }
@@ -302,7 +305,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
 		dma_cfg = devm_kzalloc(&pdev->dev, sizeof(*dma_cfg),
 				       GFP_KERNEL);
 		if (!dma_cfg) {
-			of_node_put(np);
+			of_node_put(plat->phy_node);
 			return ERR_PTR(-ENOMEM);
 		}
 		plat->dma_cfg = dma_cfg;
-- 
1.9.1

  parent reply	other threads:[~2016-08-01  7:12 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-01  7:02 [PATCH v2 00/15] add missing of_node_put after calling of_parse_phandle Peter Chen
2016-08-01  7:02 ` [PATCH v2 01/15] ethernet: altera: add missing of_node_put Peter Chen
2016-08-01  7:02 ` [PATCH v2 02/15] ethernet: apm: xgene: add missing of_node_put after calling of_parse_phandle Peter Chen
2016-08-01  7:02 ` [PATCH v2 03/15] ethernet: arc: emac_main: " Peter Chen
2016-08-01  7:02 ` [PATCH v2 04/15] ethernet: aurora: nb8800: " Peter Chen
2016-08-01  7:02 ` [PATCH v2 05/15] ethernet: cavium: octeon: " Peter Chen
2016-08-01  7:02 ` [PATCH v2 06/15] ethernet: hisilicon: hns: hns_dsaf_mac: " Peter Chen
2016-08-01  7:02 ` [PATCH v2 07/15] ethernet: hisilicon: hns: hns_dsaf_main: " Peter Chen
2016-08-01  7:02 ` [PATCH v2 08/15] ethernet: marvell: mvneta: " Peter Chen
2016-08-01  7:02 ` [PATCH v2 09/15] ethernet: marvell: mvpp2: " Peter Chen
2016-08-01  7:02 ` [PATCH v2 10/15] ethernet: marvell: pxa168_eth: " Peter Chen
2016-08-01  7:02 ` [PATCH v2 11/15] ethernet: renesas: ravb_main: " Peter Chen
2016-08-01  7:02 ` [PATCH v2 12/15] ethernet: renesas: sh_eth: " Peter Chen
2016-08-01  7:02 ` [PATCH v2 13/15] ethernet: stmicro: stmmac: dwmac-socfpga: " Peter Chen
2016-08-01  7:02 ` Peter Chen [this message]
2016-08-01  7:37   ` [PATCH v2 14/15] ethernet: stmicro: stmmac: " Alexandre Torgue
2016-08-01  7:02 ` [PATCH v2 15/15] ethernet: ti: davinci_emac: " Peter Chen
2016-08-01  8:28   ` Mugunthan V N
2016-08-02  5:14 ` [PATCH v2 00/15] " 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=1470034963-30506-15-git-send-email-peter.chen@nxp.com \
    --to=peter.chen@nxp.com \
    --cc=alexandre.torgue@st.com \
    --cc=arnd@arndb.de \
    --cc=davem@davemloft.net \
    --cc=david.daney@cavium.com \
    --cc=huangdaode@hisilicon.com \
    --cc=isubramanian@apm.com \
    --cc=jszhang@marvell.com \
    --cc=kchudgar@apm.com \
    --cc=mugunthanvnm@ti.com \
    --cc=netdev@vger.kernel.org \
    --cc=peppe.cavallaro@st.com \
    --cc=salil.mehta@huawei.com \
    --cc=sergei.shtylyov@cogentembedded.com \
    --cc=thomas.petazzoni@free-electrons.com \
    --cc=tremyfr@gmail.com \
    --cc=vbridger@opensource.altera.com \
    --cc=wxt@rock-chips.com \
    --cc=yisen.zhuang@huawei.com \
    /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).