linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cpufreq: s5pv210: add missing of_node_put
@ 2017-07-15 19:40 Julia Lawall
  2017-07-17  8:43 ` Viresh Kumar
  0 siblings, 1 reply; 2+ messages in thread
From: Julia Lawall @ 2017-07-15 19:40 UTC (permalink / raw)
  To: Kukjin Kim
  Cc: kernel-janitors, Krzysztof Kozlowski, Rafael J. Wysocki,
	Viresh Kumar, linux-arm-kernel, linux-samsung-soc, linux-pm,
	linux-kernel

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>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/cpufreq/s5pv210-cpufreq.c |    2 ++
 1 file changed, 2 insertions(+)

diff -u -p a/drivers/cpufreq/s5pv210-cpufreq.c b/drivers/cpufreq/s5pv210-cpufreq.c
--- a/drivers/cpufreq/s5pv210-cpufreq.c
+++ b/drivers/cpufreq/s5pv210-cpufreq.c
@@ -612,6 +612,7 @@ static int s5pv210_cpufreq_probe(struct
 		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 +620,7 @@ static int s5pv210_cpufreq_probe(struct
 		if (!dmc_base[id]) {
 			pr_err("%s: failed to map dmc%d registers\n",
 				__func__, id);
+			of_node_put(np);
 			return -EFAULT;
 		}
 	}

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] cpufreq: s5pv210: add missing of_node_put
  2017-07-15 19:40 [PATCH] cpufreq: s5pv210: add missing of_node_put Julia Lawall
@ 2017-07-17  8:43 ` Viresh Kumar
  0 siblings, 0 replies; 2+ messages in thread
From: Viresh Kumar @ 2017-07-17  8:43 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Kukjin Kim, kernel-janitors, Krzysztof Kozlowski,
	Rafael J. Wysocki, linux-arm-kernel, linux-samsung-soc, linux-pm,
	linux-kernel

On 15-07-17, 21:40, 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>
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> ---
>  drivers/cpufreq/s5pv210-cpufreq.c |    2 ++
>  1 file changed, 2 insertions(+)
> 
> diff -u -p a/drivers/cpufreq/s5pv210-cpufreq.c b/drivers/cpufreq/s5pv210-cpufreq.c
> --- a/drivers/cpufreq/s5pv210-cpufreq.c
> +++ b/drivers/cpufreq/s5pv210-cpufreq.c
> @@ -612,6 +612,7 @@ static int s5pv210_cpufreq_probe(struct

Just before this location we also called of_find_compatible_node()
directly and never did a of_node_put() for that. Can you please fix
that as well ?

>  		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 +620,7 @@ static int s5pv210_cpufreq_probe(struct
>  		if (!dmc_base[id]) {
>  			pr_err("%s: failed to map dmc%d registers\n",
>  				__func__, id);
> +			of_node_put(np);
>  			return -EFAULT;
>  		}
>  	}

-- 
viresh

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-07-17  8:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-15 19:40 [PATCH] cpufreq: s5pv210: add missing of_node_put Julia Lawall
2017-07-17  8:43 ` Viresh Kumar

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).