linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cpufreq: Avoid double kobject_put() for the same kobject in error code path
@ 2013-08-01 21:31 Rafael J. Wysocki
  2013-08-02  6:54 ` Srivatsa S. Bhat
  0 siblings, 1 reply; 2+ messages in thread
From: Rafael J. Wysocki @ 2013-08-01 21:31 UTC (permalink / raw)
  To: Linux PM list, cpufreq; +Cc: LKML, Srivatsa S. Bhat, Viresh Kumar

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

The only case triggering a jump to the err_out_unregister label in
__cpufreq_add_dev() is when cpufreq_add_dev_interface() fails.
However, if cpufreq_add_dev_interface() fails, it calls kobject_put()
for the policy kobject in its error code path and since that causes
the kobject's refcount to become 0, the additional kobject_put() for
the same kobject under err_out_unregister and the
wait_for_completion() following it are pointless, so drop them.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/cpufreq/cpufreq.c |    3 ---
 1 file changed, 3 deletions(-)

Index: linux-pm/drivers/cpufreq/cpufreq.c
===================================================================
--- linux-pm.orig/drivers/cpufreq/cpufreq.c
+++ linux-pm/drivers/cpufreq/cpufreq.c
@@ -1109,9 +1109,6 @@ err_out_unregister:
 	}
 	write_unlock_irqrestore(&cpufreq_driver_lock, flags);
 
-	kobject_put(&policy->kobj);
-	wait_for_completion(&policy->kobj_unregister);
-
 err_set_policy_cpu:
 	per_cpu(cpufreq_policy_cpu, cpu) = -1;
 	cpufreq_policy_free(policy);


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

* Re: [PATCH] cpufreq: Avoid double kobject_put() for the same kobject in error code path
  2013-08-01 21:31 [PATCH] cpufreq: Avoid double kobject_put() for the same kobject in error code path Rafael J. Wysocki
@ 2013-08-02  6:54 ` Srivatsa S. Bhat
  0 siblings, 0 replies; 2+ messages in thread
From: Srivatsa S. Bhat @ 2013-08-02  6:54 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: Linux PM list, cpufreq, LKML, Viresh Kumar

On 08/02/2013 03:01 AM, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> The only case triggering a jump to the err_out_unregister label in
> __cpufreq_add_dev() is when cpufreq_add_dev_interface() fails.
> However, if cpufreq_add_dev_interface() fails, it calls kobject_put()
> for the policy kobject in its error code path and since that causes
> the kobject's refcount to become 0, the additional kobject_put() for
> the same kobject under err_out_unregister and the
> wait_for_completion() following it are pointless, so drop them.
> 
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Reviewed-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>

Regards,
Srivatsa S. Bhat

> ---
>  drivers/cpufreq/cpufreq.c |    3 ---
>  1 file changed, 3 deletions(-)
> 
> Index: linux-pm/drivers/cpufreq/cpufreq.c
> ===================================================================
> --- linux-pm.orig/drivers/cpufreq/cpufreq.c
> +++ linux-pm/drivers/cpufreq/cpufreq.c
> @@ -1109,9 +1109,6 @@ err_out_unregister:
>  	}
>  	write_unlock_irqrestore(&cpufreq_driver_lock, flags);
> 
> -	kobject_put(&policy->kobj);
> -	wait_for_completion(&policy->kobj_unregister);
> -
>  err_set_policy_cpu:
>  	per_cpu(cpufreq_policy_cpu, cpu) = -1;
>  	cpufreq_policy_free(policy);
> 


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

end of thread, other threads:[~2013-08-02  6:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-01 21:31 [PATCH] cpufreq: Avoid double kobject_put() for the same kobject in error code path Rafael J. Wysocki
2013-08-02  6:54 ` Srivatsa S. Bhat

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