Skip to content

Commit 6b05048

Browse files
spandruvadarafaeljw
authored andcommitted
cpufreq: intel_pstate: Fix crash during turbo disable
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>
1 parent ab39cc4 commit 6b05048

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

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

@@ -1910,7 +1910,7 @@ static void intel_pstate_notify_work(struct work_struct *work)
19101910
struct cpudata *cpudata =
19111911
container_of(to_delayed_work(work), struct cpudata, hwp_notify_work);
19121912

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

0 commit comments

Comments
 (0)