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 13/15] ethernet: stmicro: stmmac: dwmac-socfpga: add missing of_node_put after calling of_parse_phandle
Date: Wed, 27 Jul 2016 10:20:46 +0800	[thread overview]
Message-ID: <1469586048-15697-14-git-send-email-peter.chen@nxp.com> (raw)
In-Reply-To: <1469586048-15697-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.

Signed-off-by: Peter Chen <peter.chen@nxp.com>
---
 .../net/ethernet/stmicro/stmmac/dwmac-socfpga.c    | 36 ++++++++++++++++------
 1 file changed, 26 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
index edd20c3..bec6963 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
@@ -135,7 +135,9 @@ static int socfpga_dwmac_parse_data(struct socfpga_dwmac *dwmac, struct device *
 
 	np_splitter = of_parse_phandle(np, "altr,emac-splitter", 0);
 	if (np_splitter) {
-		if (of_address_to_resource(np_splitter, 0, &res_splitter)) {
+		ret = of_address_to_resource(np_splitter, 0, &res_splitter);
+		of_node_put(np_splitter);
+		if (ret) {
 			dev_info(dev, "Missing emac splitter address\n");
 			return -EINVAL;
 		}
@@ -159,14 +161,17 @@ static int socfpga_dwmac_parse_data(struct socfpga_dwmac *dwmac, struct device *
 				dev_err(dev,
 					"%s: ERROR: missing emac splitter address\n",
 					__func__);
-				return -EINVAL;
+				ret = -EINVAL;
+				goto err_node_put;
 			}
 
 			dwmac->splitter_base =
 			    devm_ioremap_resource(dev, &res_splitter);
 
-			if (IS_ERR(dwmac->splitter_base))
-				return PTR_ERR(dwmac->splitter_base);
+			if (IS_ERR(dwmac->splitter_base)) {
+				ret = PTR_ERR(dwmac->splitter_base);
+				goto err_node_put;
+			}
 		}
 
 		index = of_property_match_string(np_sgmii_adapter, "reg-names",
@@ -178,14 +183,17 @@ static int socfpga_dwmac_parse_data(struct socfpga_dwmac *dwmac, struct device *
 				dev_err(dev,
 					"%s: ERROR: failed mapping adapter\n",
 					__func__);
-				return -EINVAL;
+				ret = -EINVAL;
+				goto err_node_put;
 			}
 
 			dwmac->pcs.sgmii_adapter_base =
 			    devm_ioremap_resource(dev, &res_sgmii_adapter);
 
-			if (IS_ERR(dwmac->pcs.sgmii_adapter_base))
-				return PTR_ERR(dwmac->pcs.sgmii_adapter_base);
+			if (IS_ERR(dwmac->pcs.sgmii_adapter_base)) {
+				ret = PTR_ERR(dwmac->pcs.sgmii_adapter_base);
+				goto err_node_put;
+			}
 		}
 
 		index = of_property_match_string(np_sgmii_adapter, "reg-names",
@@ -197,22 +205,30 @@ static int socfpga_dwmac_parse_data(struct socfpga_dwmac *dwmac, struct device *
 				dev_err(dev,
 					"%s: ERROR: failed mapping tse control port\n",
 					__func__);
-				return -EINVAL;
+				ret = -EINVAL;
+				goto err_node_put;
 			}
 
 			dwmac->pcs.tse_pcs_base =
 			    devm_ioremap_resource(dev, &res_tse_pcs);
 
-			if (IS_ERR(dwmac->pcs.tse_pcs_base))
-				return PTR_ERR(dwmac->pcs.tse_pcs_base);
+			if (IS_ERR(dwmac->pcs.tse_pcs_base)) {
+				ret = PTR_ERR(dwmac->pcs.tse_pcs_base);
+				goto err_node_put;
+			}
 		}
 	}
 	dwmac->reg_offset = reg_offset;
 	dwmac->reg_shift = reg_shift;
 	dwmac->sys_mgr_base_addr = sys_mgr_base_addr;
 	dwmac->dev = dev;
+	of_node_put(np_sgmii_adapter);
 
 	return 0;
+
+err_node_put:
+	of_node_put(np_sgmii_adapter);
+	return ret;
 }
 
 static int socfpga_dwmac_set_phy_mode(struct socfpga_dwmac *dwmac)
-- 
1.9.1

  parent reply	other threads:[~2016-07-27  2:45 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-27  2:20 [PATCH 00/15] ethernet: add missing of_node_put after calling of_parse_phandle Peter Chen
2016-07-27  2:20 ` [PATCH 01/15] ethernet: altera: add missing of_node_put Peter Chen
2016-07-27  2:20 ` [PATCH 02/15] ethernet: apm: xgene: add missing of_node_put after calling of_parse_phandle Peter Chen
2016-07-27  2:20 ` [PATCH 03/15] ethernet: arc: emac_main: " Peter Chen
2016-07-27  2:20 ` [PATCH 04/15] ethernet: aurora: nb8800: " Peter Chen
2016-07-30  6:13   ` David Miller
2016-08-01  1:19     ` Peter Chen
2016-07-27  2:20 ` [PATCH 05/15] ethernet: cavium: octeon: " Peter Chen
2016-07-27 20:56   ` David Daney
2016-07-28  1:57     ` Peter Chen
2016-07-27  2:20 ` [PATCH 06/15] ethernet: hisilicon: hns: hns_dsaf_mac: " Peter Chen
2016-07-28  0:38   ` Yisen Zhuang
2016-07-28  3:43     ` Peter Chen
2016-07-27  2:20 ` [PATCH 07/15] ethernet: hisilicon: hns: hns_dsaf_main: " Peter Chen
2016-07-27  2:20 ` [PATCH 08/15] ethernet: marvell: mvneta: " Peter Chen
2016-07-27  2:20 ` [PATCH 09/15] ethernet: marvell: mvpp2: " Peter Chen
2016-07-27  2:20 ` [PATCH 10/15] ethernet: marvell: pxa168_eth: " Peter Chen
2016-07-27  2:20 ` [PATCH 11/15] ethernet: renesas: ravb_main: " Peter Chen
2016-07-27 10:50   ` Sergei Shtylyov
2016-07-27  2:20 ` [PATCH 12/15] ethernet: renesas: sh_eth: " Peter Chen
2016-07-27 10:51   ` Sergei Shtylyov
2016-07-27  2:20 ` Peter Chen [this message]
2016-07-27  2:20 ` [PATCH 14/15] ethernet: stmicro: stmmac: stmmac_platform: " Peter Chen
2016-07-28  7:39   ` Alexandre Torgue
2016-07-28  9:30     ` Peter Chen
2016-08-01  6:50     ` Peter Chen
2016-07-27  2:20 ` [PATCH 15/15] ethernet: ti: davinci_emac: " Peter Chen
2016-07-27  5:45   ` Mugunthan V N
2016-07-27  7:43     ` Peter Chen
2016-07-29  9:29       ` Mugunthan V N
2016-08-01  1:21         ` Peter Chen

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=1469586048-15697-14-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).