From: Julia Lawall <Julia.Lawall@lip6.fr>
To: Zhang Rui <rui.zhang@intel.com>
Cc: kernel-janitors@vger.kernel.org,
Eduardo Valentin <edubezval@gmail.com>,
Thierry Reding <thierry.reding@gmail.com>,
Jonathan Hunter <jonathanh@nvidia.com>,
linux-pm@vger.kernel.org, linux-tegra@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] thermal: tegra: delete unneeded of_node_put
Date: Sat, 15 Jul 2017 10:42:32 +0200 [thread overview]
Message-ID: <1500108152-1812-1-git-send-email-Julia.Lawall@lip6.fr> (raw)
Device node iterators perform an of_node_put on each iteration, so putting
an of_node_put before a continue results in a double put.
The semantic match that finds this problem is as follows
(http://coccinelle.lip6.fr):
// <smpl>
@@
expression e1;
local idexpression child;
iterator name for_each_child_of_node;
@@
for_each_child_of_node(e1,child) {
... when != of_node_get(child)
* of_node_put(child);
...
* continue;
}
// </smpl>
Furthermore, the call to thermal_of_cooling_device_register immediately
calls __thermal_cooling_device_register with the same arguments. The
latter function stores the device node argument, which is the second
argument of for_each_child_of_node, in the returned thermal_cooling_device
structure. This returned structure is then stored in the cdev field of
stc. Thus it seems that the second argument of for_each_child_of_node
escapes the scope of the for_each_child_of_node, so an explicit of_node_get
on success of thermal_of_cooling_device_register is also needed.
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
drivers/thermal/tegra/soctherm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/soctherm.c
index 7d2db23..10f4fdd 100644
--- a/drivers/thermal/tegra/soctherm.c
+++ b/drivers/thermal/tegra/soctherm.c
@@ -1014,7 +1014,6 @@ static void soctherm_init_hw_throt_cdev(struct platform_device *pdev)
tcd = thermal_of_cooling_device_register(np_stcc,
(char *)name, ts,
&throt_cooling_ops);
- of_node_put(np_stcc);
if (IS_ERR_OR_NULL(tcd)) {
dev_err(dev,
"throttle-cfg: %s: failed to register cooling device\n",
@@ -1022,6 +1021,7 @@ static void soctherm_init_hw_throt_cdev(struct platform_device *pdev)
continue;
}
+ of_node_get(np_stcc);
stc->cdev = tcd;
stc->init = true;
}
next reply other threads:[~2017-07-15 9:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-15 8:42 Julia Lawall [this message]
[not found] ` <1500108152-1812-1-git-send-email-Julia.Lawall-L2FTfq7BK8M@public.gmane.org>
2017-07-17 13:47 ` [PATCH] thermal: tegra: delete unneeded of_node_put Jon Hunter
[not found] ` <66e7906c-9472-4fcb-7c04-750bb27d3989-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2017-07-17 14:42 ` Julia Lawall
2017-12-05 1:49 ` Eduardo Valentin
[not found] ` <20171205014918.GB3536-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2017-12-05 6:17 ` Julia Lawall
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=1500108152-1812-1-git-send-email-Julia.Lawall@lip6.fr \
--to=julia.lawall@lip6.fr \
--cc=edubezval@gmail.com \
--cc=jonathanh@nvidia.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=rui.zhang@intel.com \
--cc=thierry.reding@gmail.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