public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cpufreq: exit() callback is optional
@ 2024-04-12  5:49 Viresh Kumar
       [not found] ` <5759bc29.32d04.18ed0ef5037.Coremail.sensor1010@163.com>
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Viresh Kumar @ 2024-04-12  5:49 UTC (permalink / raw)
  To: Rafael J. Wysocki, Viresh Kumar
  Cc: linux-pm, Vincent Guittot, sensor1010, linux-kernel

The exit() callback is optional and shouldn't be called without checking
a valid pointer first.

Also, we must clear freq_table pointer even if the exit() callback isn't
present.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/cpufreq.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 66e10a19d76a..fd9c3ed21f49 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1679,10 +1679,13 @@ static void __cpufreq_offline(unsigned int cpu, struct cpufreq_policy *policy)
 	 */
 	if (cpufreq_driver->offline) {
 		cpufreq_driver->offline(policy);
-	} else if (cpufreq_driver->exit) {
-		cpufreq_driver->exit(policy);
-		policy->freq_table = NULL;
+		return;
 	}
+
+	if (cpufreq_driver->exit)
+		cpufreq_driver->exit(policy);
+
+	policy->freq_table = NULL;
 }
 
 static int cpufreq_offline(unsigned int cpu)
@@ -1740,7 +1743,7 @@ static void cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif)
 	}
 
 	/* We did light-weight exit earlier, do full tear down now */
-	if (cpufreq_driver->offline)
+	if (cpufreq_driver->offline && cpufreq_driver->exit)
 		cpufreq_driver->exit(policy);
 
 	up_write(&policy->rwsem);
-- 
2.31.1.272.g89b43f80a514


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

end of thread, other threads:[~2024-05-03 21:30 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-12  5:49 [PATCH] cpufreq: exit() callback is optional Viresh Kumar
     [not found] ` <5759bc29.32d04.18ed0ef5037.Coremail.sensor1010@163.com>
2024-04-12  6:24   ` Viresh Kumar
     [not found]     ` <1b53a162.32e95.18ed0fdb13e.Coremail.sensor1010@163.com>
2024-04-12  6:32       ` Viresh Kumar
     [not found]         ` <2117690204.533771.1712904398042.JavaMail.root@mail-tracker-145-3ep34-c9h23-5f64cf7787-82gdh>
2024-04-12  7:57           ` Greg KH
     [not found]             ` <663acff5.349d4.18ed18da6ff.Coremail.sensor1010@163.com>
2024-04-12  9:14               ` Greg KH
2024-04-12  9:23                 ` Viresh Kumar
2024-04-12  9:21               ` Viresh Kumar
2024-04-12 10:28                 ` Greg KH
     [not found]                   ` <28e13fe5.bc4.18ed2962985.Coremail.sensor1010@163.com>
2024-04-12 14:31                     ` lizhe
2024-04-12 14:41                     ` lizhe
2024-04-22 11:21                       ` shuah
     [not found]                         ` <5c601757.54f80.18f05956113.Coremail.sensor1010@163.com>
2024-05-03 21:30                           ` Shuah Khan
     [not found] ` <7bd5d6c1.32db8.18ed0f5e6c3.Coremail.sensor1010@163.com>
2024-04-12  6:27   ` Viresh Kumar
2024-04-12 11:08 ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox