Skip to content

Commit ab39cc4

Browse files
darcarirafaeljw
authored andcommitted
cpufreq: intel_pstate: Fix NULL pointer dereference in update_cpu_qos_request()
The update_cpu_qos_request() function attempts to initialize the 'freq' variable by dereferencing 'cpudata' before verifying if the 'policy' is valid. This issue occurs on systems booted with the "nosmt" parameter, where all_cpu_data[cpu] is NULL for the SMT sibling threads. As a result, any call to update_qos_requests() will result in a NULL pointer dereference as the code will attempt to access pstate.turbo_freq using the NULL cpudata pointer. Also, pstate.turbo_freq may be updated by intel_pstate_get_hwp_cap() after initializing the 'freq' variable, so it is better to defer the 'freq' until intel_pstate_get_hwp_cap() has been called. Fix this by deferring the 'freq' assignment until after the policy and driver_data have been validated. Fixes: ae1bdd2 ("cpufreq: intel_pstate: Adjust frequency percentage computations") Reported-by: Jirka Hladky <jhladky@redhat.com> Closes: https://lore.kernel.org/all/CAE4VaGDfiPvz3AzrwrwM4kWB3SCkMci25nPO8W1JmTBd=xHzZg@mail.gmail.com/ Signed-off-by: David Arcari <darcari@redhat.com> Cc: 6.18+ <stable@vger.kernel.org> # 6.18+ [ rjw: Added one paragraph to the changelog ] Link: https://patch.msgid.link/20260224122106.228116-1-darcari@redhat.com Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 6de23f8 commit ab39cc4

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/cpufreq/intel_pstate.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1647,8 +1647,8 @@ static ssize_t store_no_turbo(struct kobject *a, struct kobj_attribute *b,
16471647
static void update_cpu_qos_request(int cpu, enum freq_qos_req_type type)
16481648
{
16491649
struct cpudata *cpudata = all_cpu_data[cpu];
1650-
unsigned int freq = cpudata->pstate.turbo_freq;
16511650
struct freq_qos_request *req;
1651+
unsigned int freq;
16521652

16531653
struct cpufreq_policy *policy __free(put_cpufreq_policy) = cpufreq_cpu_get(cpu);
16541654
if (!policy)
@@ -1661,6 +1661,8 @@ static void update_cpu_qos_request(int cpu, enum freq_qos_req_type type)
16611661
if (hwp_active)
16621662
intel_pstate_get_hwp_cap(cpudata);
16631663

1664+
freq = cpudata->pstate.turbo_freq;
1665+
16641666
if (type == FREQ_QOS_MIN) {
16651667
freq = DIV_ROUND_UP(freq * global.min_perf_pct, 100);
16661668
} else {

0 commit comments

Comments
 (0)