From: Dennis Beier <nanovim@gmail.com>
To: rafael@kernel.org, viresh.kumar@linaro.org
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
Dennis Beier <nanovim@gmail.com>
Subject: [PATCH RESEND] cpufreq/longhaul: handle NULL policy in longhaul_exit
Date: Thu, 28 Aug 2025 23:29:36 +0200 [thread overview]
Message-ID: <20250828213427.27593-1-nanovim@gmail.com> (raw)
Resending this patch to include cpufreq maintainers.
---
longhaul_exit() was calling cpufreq_cpu_get(0) without checking
for a NULL policy pointer. On some systems, this could lead to a
NULL dereference and a kernel warning or panic.
This patch adds a check using unlikely() and prints a warning
if the policy is NULL, then returns early. Also, the loop variable
is now declared inside the for-loop to match modern kernel style.
Bugzilla: #219962
Signed-off-by: Dennis Beier <nanovim@gmail.com>
---
drivers/cpufreq/longhaul.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/cpufreq/longhaul.c b/drivers/cpufreq/longhaul.c
index ba0e08c8486a..9698d56bfe6c 100644
--- a/drivers/cpufreq/longhaul.c
+++ b/drivers/cpufreq/longhaul.c
@@ -951,9 +951,14 @@ static int __init longhaul_init(void)
static void __exit longhaul_exit(void)
{
struct cpufreq_policy *policy = cpufreq_cpu_get(0);
- int i;
+ if (unlikely(!policy)) {
+ pr_warn_once("longhaul_exit: policy is NULL\n");
+
+ return;
+ }
+
- for (i = 0; i < numscales; i++) {
+ for (int i = 0; i < numscales; i++) {
if (mults[i] == maxmult) {
struct cpufreq_freqs freqs;
--
2.50.1
next reply other threads:[~2025-08-28 21:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-28 21:29 Dennis Beier [this message]
2025-08-29 4:15 ` [PATCH RESEND] cpufreq/longhaul: handle NULL policy in longhaul_exit Viresh Kumar
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=20250828213427.27593-1-nanovim@gmail.com \
--to=nanovim@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=viresh.kumar@linaro.org \
/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;
as well as URLs for NNTP newsgroup(s).