Skip to content

Commit ca19f3f

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 882f784 commit ca19f3f

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

drivers/cpufreq/cpufreq.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2762,10 +2762,18 @@ EXPORT_SYMBOL(cpufreq_update_policy);
27622762
*/
27632763
void cpufreq_update_limits(unsigned int cpu)
27642764
{
2765+
struct cpufreq_policy *policy;
2766+
2767+
policy = cpufreq_cpu_get(cpu);
2768+
if (!policy)
2769+
return;
2770+
27652771
if (cpufreq_driver->update_limits)
27662772
cpufreq_driver->update_limits(cpu);
27672773
else
27682774
cpufreq_update_policy(cpu);
2775+
2776+
cpufreq_cpu_put(policy);
27692777
}
27702778
EXPORT_SYMBOL_GPL(cpufreq_update_limits);
27712779

0 commit comments

Comments
 (0)