[PATCH] cpufreq: Make cpufreq_online() call driver->offline() on errors
From: Rafael J. Wysocki
Date: Mon Jun 21 2021 - 13:26:18 EST
From: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
In the CPU removal path the ->offline() callback provided by the
driver is always invoked before ->exit(), but in the cpufreq_online()
error path it is not, so ->exit() is somehow expected to know the
context in which it has been called and act accordingly.
That is less than straightforward, so make cpufreq_online() invoke
the driver's ->offline() callback before ->exit() too.
This only potentially affects intel_pstate at this point.
Fixes: 91a12e91dc39 ("cpufreq: Allow light-weight tear down and bring up of CPUs")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
---
drivers/cpufreq/cpufreq.c | 3 +++
1 file changed, 3 insertions(+)
Index: linux-pm/drivers/cpufreq/cpufreq.c
===================================================================
--- linux-pm.orig/drivers/cpufreq/cpufreq.c
+++ linux-pm/drivers/cpufreq/cpufreq.c
@@ -1516,6 +1516,9 @@ out_destroy_policy:
up_write(&policy->rwsem);
out_exit_policy:
+ if (cpufreq_driver->offline)
+ cpufreq_driver->offline(policy);
+
if (cpufreq_driver->exit)
cpufreq_driver->exit(policy);