From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Linux PM <linux-pm@vger.kernel.org>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
LKML <linux-kernel@vger.kernel.org>,
Viresh Kumar <viresh.kumar@linaro.org>,
Zihuan Zhang <zhangzihuan@kylinos.cn>,
Jonathan Cameron <jonathan.cameron@huawei.com>
Subject: [PATCH v1 1/3] cpufreq: intel_pstate: Fix object lifecycle issue in update_qos_request()
Date: Fri, 05 Sep 2025 15:52:03 +0200 [thread overview]
Message-ID: <2255671.irdbgypaU6@rafael.j.wysocki> (raw)
In-Reply-To: <5028967.GXAFRqVoOG@rafael.j.wysocki>
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
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: da5c504c7aae ("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>
---
drivers/cpufreq/intel_pstate.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -1708,10 +1708,10 @@ static void update_qos_request(enum freq
continue;
req = policy->driver_data;
- cpufreq_cpu_put(policy);
-
- if (!req)
+ if (!req) {
+ cpufreq_cpu_put(policy);
continue;
+ }
if (hwp_active)
intel_pstate_get_hwp_cap(cpu);
@@ -1727,6 +1727,8 @@ static void update_qos_request(enum freq
if (freq_qos_update_request(req, freq) < 0)
pr_warn("Failed to update freq constraint: CPU%d\n", i);
+
+ cpufreq_cpu_put(policy);
}
}
next prev parent reply other threads:[~2025-09-05 13:54 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-05 13:51 [PATCH v1 0/3] cpufreq: intel_pstate: A fix, a __free()-based simplification, and a follow-up adjustment Rafael J. Wysocki
2025-09-05 13:52 ` Rafael J. Wysocki [this message]
2025-09-08 0:41 ` [PATCH v1 1/3] cpufreq: intel_pstate: Fix object lifecycle issue in update_qos_request() Zihuan Zhang
2025-09-05 13:52 ` [PATCH v1 2/3] cpufreq: intel_pstate: Rearrange freq QoS updates using __free() Rafael J. Wysocki
2025-09-08 0:53 ` Zihuan Zhang
2025-09-08 18:10 ` Rafael J. Wysocki
2025-09-09 0:47 ` Zihuan Zhang
2025-09-05 13:53 ` [PATCH v1 3/3] cpufreq: intel_pstate: Adjust frequency percentage computations Rafael J. Wysocki
2025-09-08 1:12 ` [PATCH v1 3/3] cpufreq: intel_pstate: Adjust frequency percentage Zihuan Zhang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2255671.irdbgypaU6@rafael.j.wysocki \
--to=rafael@kernel.org \
--cc=jonathan.cameron@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=srinivas.pandruvada@linux.intel.com \
--cc=viresh.kumar@linaro.org \
--cc=zhangzihuan@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox