linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cpufreq: ti: Fix 'of_node_put' being called twice in error handling path
@ 2017-08-19 20:22 Christophe JAILLET
  2017-08-20 13:21 ` Viresh Kumar
  0 siblings, 1 reply; 3+ messages in thread
From: Christophe JAILLET @ 2017-08-19 20:22 UTC (permalink / raw)
  To: rjw, viresh.kumar
  Cc: linux-pm, linux-kernel, kernel-janitors, Christophe JAILLET

If 'dev_pm_opp_set_supported_hw()' fails, 'opp_data->opp_node' refcount
will be decremented 2 times.
One, just a few lines above, and another one in the error handling path.

Fix it by simply moving the 'of_node_put' call of the normal path.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/cpufreq/ti-cpufreq.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/cpufreq/ti-cpufreq.c b/drivers/cpufreq/ti-cpufreq.c
index a7b5658c0460..b29cd3398463 100644
--- a/drivers/cpufreq/ti-cpufreq.c
+++ b/drivers/cpufreq/ti-cpufreq.c
@@ -245,8 +245,6 @@ static int ti_cpufreq_init(void)
 	if (ret)
 		goto fail_put_node;
 
-	of_node_put(opp_data->opp_node);
-
 	ret = PTR_ERR_OR_ZERO(dev_pm_opp_set_supported_hw(opp_data->cpu_dev,
 							  version, VERSION_COUNT));
 	if (ret) {
@@ -255,6 +253,8 @@ static int ti_cpufreq_init(void)
 		goto fail_put_node;
 	}
 
+	of_node_put(opp_data->opp_node);
+
 register_cpufreq_dt:
 	platform_device_register_simple("cpufreq-dt", -1, NULL, 0);
 
-- 
2.11.0

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

* Re: [PATCH] cpufreq: ti: Fix 'of_node_put' being called twice in error handling path
  2017-08-19 20:22 [PATCH] cpufreq: ti: Fix 'of_node_put' being called twice in error handling path Christophe JAILLET
@ 2017-08-20 13:21 ` Viresh Kumar
  2017-08-28 21:21   ` Rafael J. Wysocki
  0 siblings, 1 reply; 3+ messages in thread
From: Viresh Kumar @ 2017-08-20 13:21 UTC (permalink / raw)
  To: Christophe JAILLET; +Cc: rjw, linux-pm, linux-kernel, kernel-janitors

On 19-08-17, 22:22, Christophe JAILLET wrote:
> If 'dev_pm_opp_set_supported_hw()' fails, 'opp_data->opp_node' refcount
> will be decremented 2 times.
> One, just a few lines above, and another one in the error handling path.
> 
> Fix it by simply moving the 'of_node_put' call of the normal path.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/cpufreq/ti-cpufreq.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/cpufreq/ti-cpufreq.c b/drivers/cpufreq/ti-cpufreq.c
> index a7b5658c0460..b29cd3398463 100644
> --- a/drivers/cpufreq/ti-cpufreq.c
> +++ b/drivers/cpufreq/ti-cpufreq.c
> @@ -245,8 +245,6 @@ static int ti_cpufreq_init(void)
>  	if (ret)
>  		goto fail_put_node;
>  
> -	of_node_put(opp_data->opp_node);
> -
>  	ret = PTR_ERR_OR_ZERO(dev_pm_opp_set_supported_hw(opp_data->cpu_dev,
>  							  version, VERSION_COUNT));
>  	if (ret) {
> @@ -255,6 +253,8 @@ static int ti_cpufreq_init(void)
>  		goto fail_put_node;
>  	}
>  
> +	of_node_put(opp_data->opp_node);
> +
>  register_cpufreq_dt:
>  	platform_device_register_simple("cpufreq-dt", -1, NULL, 0);

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

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

* Re: [PATCH] cpufreq: ti: Fix 'of_node_put' being called twice in error handling path
  2017-08-20 13:21 ` Viresh Kumar
@ 2017-08-28 21:21   ` Rafael J. Wysocki
  0 siblings, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2017-08-28 21:21 UTC (permalink / raw)
  To: Viresh Kumar, Christophe JAILLET; +Cc: linux-pm, linux-kernel, kernel-janitors

On Sunday, August 20, 2017 3:21:06 PM CEST Viresh Kumar wrote:
> On 19-08-17, 22:22, Christophe JAILLET wrote:
> > If 'dev_pm_opp_set_supported_hw()' fails, 'opp_data->opp_node' refcount
> > will be decremented 2 times.
> > One, just a few lines above, and another one in the error handling path.
> > 
> > Fix it by simply moving the 'of_node_put' call of the normal path.
> > 
> > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> > ---
> >  drivers/cpufreq/ti-cpufreq.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/cpufreq/ti-cpufreq.c b/drivers/cpufreq/ti-cpufreq.c
> > index a7b5658c0460..b29cd3398463 100644
> > --- a/drivers/cpufreq/ti-cpufreq.c
> > +++ b/drivers/cpufreq/ti-cpufreq.c
> > @@ -245,8 +245,6 @@ static int ti_cpufreq_init(void)
> >  	if (ret)
> >  		goto fail_put_node;
> >  
> > -	of_node_put(opp_data->opp_node);
> > -
> >  	ret = PTR_ERR_OR_ZERO(dev_pm_opp_set_supported_hw(opp_data->cpu_dev,
> >  							  version, VERSION_COUNT));
> >  	if (ret) {
> > @@ -255,6 +253,8 @@ static int ti_cpufreq_init(void)
> >  		goto fail_put_node;
> >  	}
> >  
> > +	of_node_put(opp_data->opp_node);
> > +
> >  register_cpufreq_dt:
> >  	platform_device_register_simple("cpufreq-dt", -1, NULL, 0);
> 
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
> 
> 

Applied, thanks!

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

end of thread, other threads:[~2017-08-28 21:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-19 20:22 [PATCH] cpufreq: ti: Fix 'of_node_put' being called twice in error handling path Christophe JAILLET
2017-08-20 13:21 ` Viresh Kumar
2017-08-28 21:21   ` Rafael J. Wysocki

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