Skip to content

Commit d20d489

Browse files
spandruvadaSasha Levin
authored andcommitted
cpufreq: intel_pstate: Fix crash during turbo disable
commit 6b05048 upstream. When the system is booted with kernel command line argument "nosmt" or "maxcpus" to limit the number of CPUs, disabling turbo via: echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo results in a crash: PF: supervisor read access in kernel mode PF: error_code(0x0000) - not-present page PGD 0 P4D 0 Oops: Oops: 0000 [#1] SMP PTI ... RIP: 0010:store_no_turbo+0x100/0x1f0 ... This occurs because for_each_possible_cpu() returns CPUs even if they are not online. For those CPUs, all_cpu_data[] will be NULL. Since commit 973207a ("cpufreq: intel_pstate: Rearrange max frequency updates handling code"), all_cpu_data[] is dereferenced even for CPUs which are not online, causing the NULL pointer dereference. To fix that, pass CPU number to intel_pstate_update_max_freq() and use all_cpu_data[] for those CPUs for which there is a valid cpufreq policy. Fixes: 973207a ("cpufreq: intel_pstate: Rearrange max frequency updates handling code") Closes: https://bugzilla.kernel.org/show_bug.cgi?id=221068 Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Cc: 6.16+ <stable@vger.kernel.org> # 6.16+ Link: https://patch.msgid.link/20260225001752.890164-1-srinivas.pandruvada@linux.intel.com Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f4588b8 commit d20d489

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/cpufreq/intel_pstate.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,13 +1476,13 @@ static void __intel_pstate_update_max_freq(struct cpufreq_policy *policy,
14761476
refresh_frequency_limits(policy);
14771477
}
14781478

1479-
static bool intel_pstate_update_max_freq(struct cpudata *cpudata)
1479+
static bool intel_pstate_update_max_freq(int cpu)
14801480
{
1481-
struct cpufreq_policy *policy __free(put_cpufreq_policy) = cpufreq_cpu_get(cpudata->cpu);
1481+
struct cpufreq_policy *policy __free(put_cpufreq_policy) = cpufreq_cpu_get(cpu);
14821482
if (!policy)
14831483
return false;
14841484

1485-
__intel_pstate_update_max_freq(policy, cpudata);
1485+
__intel_pstate_update_max_freq(policy, all_cpu_data[cpu]);
14861486

14871487
return true;
14881488
}
@@ -1501,7 +1501,7 @@ static void intel_pstate_update_limits_for_all(void)
15011501
int cpu;
15021502

15031503
for_each_possible_cpu(cpu)
1504-
intel_pstate_update_max_freq(all_cpu_data[cpu]);
1504+
intel_pstate_update_max_freq(cpu);
15051505

15061506
mutex_lock(&hybrid_capacity_lock);
15071507

@@ -1908,7 +1908,7 @@ static void intel_pstate_notify_work(struct work_struct *work)
19081908
struct cpudata *cpudata =
19091909
container_of(to_delayed_work(work), struct cpudata, hwp_notify_work);
19101910

1911-
if (intel_pstate_update_max_freq(cpudata)) {
1911+
if (intel_pstate_update_max_freq(cpudata->cpu)) {
19121912
/*
19131913
* The driver will not be unregistered while this function is
19141914
* running, so update the capacity without acquiring the driver

0 commit comments

Comments
 (0)