Skip to content

Commit 69e5d50

Browse files
committed
cpufreq: intel_pstate: Fix object lifecycle issue in update_qos_request()
The cpufreq_cpu_put() call in update_qos_request() takes place too early because the latter subsequently calls freq_qos_update_request() that indirectly accesses the policy object in question through the QoS request object passed to it. Fortunately, update_qos_request() is called under intel_pstate_driver_lock, so this issue does not matter for changing the intel_pstate operation mode, but it theoretically can cause a crash to occur on CPU device hot removal (which currently can only happen in virt, but it is formally supported nevertheless). Address this issue by modifying update_qos_request() to drop the reference to the policy later. Fixes: da5c504 ("cpufreq: intel_pstate: Implement QoS supported freq constraints") Cc: 5.4+ <stable@vger.kernel.org> # 5.4+ Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Zihuan Zhang <zhangzihuan@kylinos.cn> Link: https://patch.msgid.link/2255671.irdbgypaU6@rafael.j.wysocki
1 parent 42c74f6 commit 69e5d50

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

drivers/cpufreq/intel_pstate.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1667,10 +1667,10 @@ static void update_qos_request(enum freq_qos_req_type type)
16671667
continue;
16681668

16691669
req = policy->driver_data;
1670-
cpufreq_cpu_put(policy);
1671-
1672-
if (!req)
1670+
if (!req) {
1671+
cpufreq_cpu_put(policy);
16731672
continue;
1673+
}
16741674

16751675
if (hwp_active)
16761676
intel_pstate_get_hwp_cap(cpu);
@@ -1686,6 +1686,8 @@ static void update_qos_request(enum freq_qos_req_type type)
16861686

16871687
if (freq_qos_update_request(req, freq) < 0)
16881688
pr_warn("Failed to update freq constraint: CPU%d\n", i);
1689+
1690+
cpufreq_cpu_put(policy);
16891691
}
16901692
}
16911693

0 commit comments

Comments
 (0)