From: <Yuantian.Tang@freescale.com>
To: <grant.likely@secretlab.ca>
Cc: Tang Yuantian <Yuantian.Tang@freescale.com>,
devicetree-discuss@lists.ozlabs.org,
linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
rob.herring@calxeda.com
Subject: [PATCH v2] of/base: release the node correctly in of_parse_phandle_with_args()
Date: Wed, 10 Apr 2013 11:36:39 +0800 [thread overview]
Message-ID: <1365564999-24427-1-git-send-email-Yuantian.Tang@freescale.com> (raw)
From: Tang Yuantian <yuantian.tang@freescale.com>
Call of_node_put() only when the out_args is NULL on success,
or the node's reference count will not be correct because the caller
will call of_node_put() again.
Signed-off-by: Tang Yuantian <Yuantian.Tang@freescale.com>
---
v2:
- modified the title and description. the 1st patch title is:
of: remove the unnecessary of_node_put for of_parse_phandle_with_args()
the 1st patch is not good enough.
drivers/of/base.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 321d3ef..ee94f64 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1158,6 +1158,7 @@ static int __of_parse_phandle_with_args(const struct device_node *np,
if (!phandle)
goto err;
+ /* Found it! return success */
if (out_args) {
int i;
if (WARN_ON(count > MAX_PHANDLE_ARGS))
@@ -1166,11 +1167,10 @@ static int __of_parse_phandle_with_args(const struct device_node *np,
out_args->args_count = count;
for (i = 0; i < count; i++)
out_args->args[i] = be32_to_cpup(list++);
+ } else if (node) {
+ of_node_put(node);
}
- /* Found it! return success */
- if (node)
- of_node_put(node);
return 0;
}
--
1.8.0
next reply other threads:[~2013-04-10 3:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-10 3:36 Yuantian.Tang [this message]
2013-04-16 6:54 ` [PATCH v2] of/base: release the node correctly in of_parse_phandle_with_args() Tang Yuantian-B29983
2013-04-17 14:57 ` Grant Likely
2013-04-17 21:52 ` Timur Tabi
2013-04-17 22:00 ` Grant Likely
2013-04-16 11:37 ` Timur Tabi
2013-04-17 2:44 ` Tang Yuantian-B29983
2013-04-17 3:30 ` Timur Tabi
2013-04-17 4:49 ` Tang Yuantian-B29983
2013-04-17 11:27 ` Timur Tabi
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=1365564999-24427-1-git-send-email-Yuantian.Tang@freescale.com \
--to=yuantian.tang@freescale.com \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=grant.likely@secretlab.ca \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=rob.herring@calxeda.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).