Skip to content

Commit 18bf3a1

Browse files
vireshkrafaeljw
authored andcommitted
cpufreq: Mark policy->governor = NULL for inactive policies
Later commits would change the way policies are managed today. Policies wouldn't be freed on cpu hotplug (currently they aren't freed on suspend), and while the CPU is offline, the sysfs cpufreq files would still be present. Because we don't mark policy->governor as NULL, it still contains pointer of the last used governor. And if the governor is removed, while all the CPUs of a policy are hotplugged out, this pointer wouldn't be valid anymore. And if we try to read the 'scaling_governor', etc. from sysfs, it will result in kernel OOPs. To prevent this, mark policy->governor as NULL for all inactive policies while the governor is removed from kernel. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 4573237 commit 18bf3a1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/cpufreq/cpufreq.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,6 @@ static struct cpufreq_policy *cpufreq_policy_restore(unsigned int cpu)
10831083
if (likely(policy)) {
10841084
/* Policy should be inactive here */
10851085
WARN_ON(!policy_is_inactive(policy));
1086-
policy->governor = NULL;
10871086
}
10881087

10891088
return policy;
@@ -2145,8 +2144,10 @@ void cpufreq_unregister_governor(struct cpufreq_governor *governor)
21452144
/* clear last_governor for all inactive policies */
21462145
read_lock_irqsave(&cpufreq_driver_lock, flags);
21472146
for_each_inactive_policy(policy) {
2148-
if (!strcmp(policy->last_governor, governor->name))
2147+
if (!strcmp(policy->last_governor, governor->name)) {
2148+
policy->governor = NULL;
21492149
strcpy(policy->last_governor, "\0");
2150+
}
21502151
}
21512152
read_unlock_irqrestore(&cpufreq_driver_lock, flags);
21522153

0 commit comments

Comments
 (0)