]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
cpufreq: Reference count policy in cpufreq_update_limits()
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 28 Mar 2025 20:39:08 +0000 (21:39 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 2 May 2025 05:41:03 +0000 (07:41 +0200)
commit 9e4e249018d208678888bdf22f6b652728106528 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: 5a25e3f7cc53 ("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>
drivers/cpufreq/cpufreq.c

index 162de402b1134031d5b3fe3a5e7b6e5ad9ccd9eb..d13139497da44291ac5e87df00610aa75b2de79f 100644 (file)
@@ -2593,10 +2593,18 @@ EXPORT_SYMBOL(cpufreq_update_policy);
  */
 void cpufreq_update_limits(unsigned int cpu)
 {
+       struct cpufreq_policy *policy;
+
+       policy = cpufreq_cpu_get(cpu);
+       if (!policy)
+               return;
+
        if (cpufreq_driver->update_limits)
                cpufreq_driver->update_limits(cpu);
        else
                cpufreq_update_policy(cpu);
+
+       cpufreq_cpu_put(policy);
 }
 EXPORT_SYMBOL_GPL(cpufreq_update_limits);