Skip to content

Commit c1a485c

Browse files
rafaeljwgregkh
authored andcommitted
cpufreq: Reference count policy in cpufreq_update_limits()
commit 9e4e249 upstream. Since acpi_processor_notify() can be called before registering a cpufreq driver or even in cases when a cpufreq driver is not registered at all, cpufreq_update_limits() needs to check if a cpufreq driver is present and prevent it from being unregistered. For this purpose, make it call cpufreq_cpu_get() to obtain a cpufreq policy pointer for the given CPU and reference count the corresponding policy object, if present. Fixes: 5a25e3f ("cpufreq: intel_pstate: Driver-specific handling of _PPC updates") Closes: https://lore.kernel.org/linux-acpi/Z-ShAR59cTow0KcR@mail-itl Reported-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com> Cc: All applicable <stable@vger.kernel.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Link: https://patch.msgid.link/1928789.tdWV9SEqCh@rjwysocki.net [do not use __free(cpufreq_cpu_put) in a backport] Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 686d8f7 commit c1a485c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

drivers/cpufreq/cpufreq.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2748,10 +2748,18 @@ EXPORT_SYMBOL(cpufreq_update_policy);
27482748
*/
27492749
void cpufreq_update_limits(unsigned int cpu)
27502750
{
2751+
struct cpufreq_policy *policy;
2752+
2753+
policy = cpufreq_cpu_get(cpu);
2754+
if (!policy)
2755+
return;
2756+
27512757
if (cpufreq_driver->update_limits)
27522758
cpufreq_driver->update_limits(cpu);
27532759
else
27542760
cpufreq_update_policy(cpu);
2761+
2762+
cpufreq_cpu_put(policy);
27552763
}
27562764
EXPORT_SYMBOL_GPL(cpufreq_update_limits);
27572765

0 commit comments

Comments
 (0)