Skip to content

Commit b8f8583

Browse files
vireshkrafaeljw
authored andcommitted
cpufreq: exit() callback is optional
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 <[email protected]> Fixes: 91a12e9 ("cpufreq: Allow light-weight tear down and bring up of CPUs") Fixes: f339f35 ("cpufreq: Rearrange locking in cpufreq_remove_dev()") Reported-by: Lizhe <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 5196123 commit b8f8583

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

drivers/cpufreq/cpufreq.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,10 +1679,13 @@ static void __cpufreq_offline(unsigned int cpu, struct cpufreq_policy *policy)
16791679
*/
16801680
if (cpufreq_driver->offline) {
16811681
cpufreq_driver->offline(policy);
1682-
} else if (cpufreq_driver->exit) {
1683-
cpufreq_driver->exit(policy);
1684-
policy->freq_table = NULL;
1682+
return;
16851683
}
1684+
1685+
if (cpufreq_driver->exit)
1686+
cpufreq_driver->exit(policy);
1687+
1688+
policy->freq_table = NULL;
16861689
}
16871690

16881691
static int cpufreq_offline(unsigned int cpu)
@@ -1740,7 +1743,7 @@ static void cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif)
17401743
}
17411744

17421745
/* We did light-weight exit earlier, do full tear down now */
1743-
if (cpufreq_driver->offline)
1746+
if (cpufreq_driver->offline && cpufreq_driver->exit)
17441747
cpufreq_driver->exit(policy);
17451748

17461749
up_write(&policy->rwsem);

0 commit comments

Comments
 (0)