Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1693954 > unrolled thread
| Started by | Julia Lawall <Julia.Lawall@lip6.fr> |
|---|---|
| First post | 2017-07-21 22:20 +0200 |
| Last post | 2017-07-28 02:10 +0200 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH v2] cpufreq: s5pv210: add missing of_node_put Julia Lawall <Julia.Lawall@lip6.fr> - 2017-07-21 22:20 +0200
Re: [PATCH v2] cpufreq: s5pv210: add missing of_node_put Viresh Kumar <viresh.kumar@linaro.org> - 2017-07-24 11:00 +0200
Re: [PATCH v2] cpufreq: s5pv210: add missing of_node_put "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2017-07-28 02:10 +0200
| From | Julia Lawall <Julia.Lawall@lip6.fr> |
|---|---|
| Date | 2017-07-21 22:20 +0200 |
| Subject | [PATCH v2] cpufreq: s5pv210: add missing of_node_put |
| Message-ID | <u5MyZ-Tz-1@gated-at.bofh.it> |
for_each_compatible_node performs an of_node_get on each iteration, so a
return from the loop requires an of_node_put.
The semantic patch that fixes this problem is as follows
(http://coccinelle.lip6.fr):
// <smpl>
@@
local idexpression n;
expression e,e1,e2;
statement S;
iterator i1;
iterator name for_each_compatible_node;
@@
for_each_compatible_node(n,e1,e2) {
...
(
of_node_put(n);
|
e = n
|
return n;
|
i1(...,n,...) S
|
+ of_node_put(n);
? return ...;
)
...
}
// </smpl>
Additionally, call of_node_put on the previous value of np, obtained from
of_find_compatible_node, that is no longer accessible at the point of the
for_each_compatible_node.
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
v2: add the of_node_put for the call to of_find_compatible_node as well.
drivers/cpufreq/s5pv210-cpufreq.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/cpufreq/s5pv210-cpufreq.c b/drivers/cpufreq/s5pv210-cpufreq.c
index f82074e..5d31c2d 100644
--- a/drivers/cpufreq/s5pv210-cpufreq.c
+++ b/drivers/cpufreq/s5pv210-cpufreq.c
@@ -602,6 +602,7 @@ static int s5pv210_cpufreq_probe(struct platform_device *pdev)
}
clk_base = of_iomap(np, 0);
+ of_node_put(np);
if (!clk_base) {
pr_err("%s: failed to map clock registers\n", __func__);
return -EFAULT;
@@ -612,6 +613,7 @@ static int s5pv210_cpufreq_probe(struct platform_device *pdev)
if (id < 0 || id >= ARRAY_SIZE(dmc_base)) {
pr_err("%s: failed to get alias of dmc node '%s'\n",
__func__, np->name);
+ of_node_put(np);
return id;
}
@@ -619,6 +621,7 @@ static int s5pv210_cpufreq_probe(struct platform_device *pdev)
if (!dmc_base[id]) {
pr_err("%s: failed to map dmc%d registers\n",
__func__, id);
+ of_node_put(np);
return -EFAULT;
}
}
[toc] | [next] | [standalone]
| From | Viresh Kumar <viresh.kumar@linaro.org> |
|---|---|
| Date | 2017-07-24 11:00 +0200 |
| Message-ID | <u6HnB-2u7-35@gated-at.bofh.it> |
| In reply to | #1693954 |
On 21-07-17, 21:53, Julia Lawall wrote:
> for_each_compatible_node performs an of_node_get on each iteration, so a
> return from the loop requires an of_node_put.
>
> The semantic patch that fixes this problem is as follows
> (http://coccinelle.lip6.fr):
>
> // <smpl>
> @@
> local idexpression n;
> expression e,e1,e2;
> statement S;
> iterator i1;
> iterator name for_each_compatible_node;
> @@
>
> for_each_compatible_node(n,e1,e2) {
> ...
> (
> of_node_put(n);
> |
> e = n
> |
> return n;
> |
> i1(...,n,...) S
> |
> + of_node_put(n);
> ? return ...;
> )
> ...
> }
> // </smpl>
>
> Additionally, call of_node_put on the previous value of np, obtained from
> of_find_compatible_node, that is no longer accessible at the point of the
> for_each_compatible_node.
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
>
> ---
>
> v2: add the of_node_put for the call to of_find_compatible_node as well.
>
> drivers/cpufreq/s5pv210-cpufreq.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/cpufreq/s5pv210-cpufreq.c b/drivers/cpufreq/s5pv210-cpufreq.c
> index f82074e..5d31c2d 100644
> --- a/drivers/cpufreq/s5pv210-cpufreq.c
> +++ b/drivers/cpufreq/s5pv210-cpufreq.c
> @@ -602,6 +602,7 @@ static int s5pv210_cpufreq_probe(struct platform_device *pdev)
> }
>
> clk_base = of_iomap(np, 0);
> + of_node_put(np);
> if (!clk_base) {
> pr_err("%s: failed to map clock registers\n", __func__);
> return -EFAULT;
> @@ -612,6 +613,7 @@ static int s5pv210_cpufreq_probe(struct platform_device *pdev)
> if (id < 0 || id >= ARRAY_SIZE(dmc_base)) {
> pr_err("%s: failed to get alias of dmc node '%s'\n",
> __func__, np->name);
> + of_node_put(np);
> return id;
> }
>
> @@ -619,6 +621,7 @@ static int s5pv210_cpufreq_probe(struct platform_device *pdev)
> if (!dmc_base[id]) {
> pr_err("%s: failed to map dmc%d registers\n",
> __func__, id);
> + of_node_put(np);
> return -EFAULT;
> }
> }
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
--
viresh
[toc] | [prev] | [next] | [standalone]
| From | "Rafael J. Wysocki" <rjw@rjwysocki.net> |
|---|---|
| Date | 2017-07-28 02:10 +0200 |
| Message-ID | <u810R-4Ek-1@gated-at.bofh.it> |
| In reply to | #1694553 |
On Monday, July 24, 2017 02:22:16 PM Viresh Kumar wrote:
> On 21-07-17, 21:53, Julia Lawall wrote:
> > for_each_compatible_node performs an of_node_get on each iteration, so a
> > return from the loop requires an of_node_put.
> >
> > The semantic patch that fixes this problem is as follows
> > (http://coccinelle.lip6.fr):
> >
> > // <smpl>
> > @@
> > local idexpression n;
> > expression e,e1,e2;
> > statement S;
> > iterator i1;
> > iterator name for_each_compatible_node;
> > @@
> >
> > for_each_compatible_node(n,e1,e2) {
> > ...
> > (
> > of_node_put(n);
> > |
> > e = n
> > |
> > return n;
> > |
> > i1(...,n,...) S
> > |
> > + of_node_put(n);
> > ? return ...;
> > )
> > ...
> > }
> > // </smpl>
> >
> > Additionally, call of_node_put on the previous value of np, obtained from
> > of_find_compatible_node, that is no longer accessible at the point of the
> > for_each_compatible_node.
> >
> > Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> >
> > ---
> >
> > v2: add the of_node_put for the call to of_find_compatible_node as well.
> >
> > drivers/cpufreq/s5pv210-cpufreq.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/cpufreq/s5pv210-cpufreq.c b/drivers/cpufreq/s5pv210-cpufreq.c
> > index f82074e..5d31c2d 100644
> > --- a/drivers/cpufreq/s5pv210-cpufreq.c
> > +++ b/drivers/cpufreq/s5pv210-cpufreq.c
> > @@ -602,6 +602,7 @@ static int s5pv210_cpufreq_probe(struct platform_device *pdev)
> > }
> >
> > clk_base = of_iomap(np, 0);
> > + of_node_put(np);
> > if (!clk_base) {
> > pr_err("%s: failed to map clock registers\n", __func__);
> > return -EFAULT;
> > @@ -612,6 +613,7 @@ static int s5pv210_cpufreq_probe(struct platform_device *pdev)
> > if (id < 0 || id >= ARRAY_SIZE(dmc_base)) {
> > pr_err("%s: failed to get alias of dmc node '%s'\n",
> > __func__, np->name);
> > + of_node_put(np);
> > return id;
> > }
> >
> > @@ -619,6 +621,7 @@ static int s5pv210_cpufreq_probe(struct platform_device *pdev)
> > if (!dmc_base[id]) {
> > pr_err("%s: failed to map dmc%d registers\n",
> > __func__, id);
> > + of_node_put(np);
> > return -EFAULT;
> > }
> > }
>
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
>
>
Applied, thanks!
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web