From: Zihuan Zhang <zzhwaxy.kernel@gmail.com>
To: "Rafael J . Wysocki" <rafael@kernel.org>,
Viresh Kumar <viresh.kumar@linaro.org>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
Zihuan Zhang <zzhwaxy.kernel@gmail.com>
Subject: [PATCH v1] cpufreq: Avoid creating sysfs link for offline CPUs
Date: Mon, 21 Jul 2025 23:36:56 +0800 [thread overview]
Message-ID: <20250721153656.5103-1-zzhwaxy.kernel@gmail.com> (raw)
Currently, cpufreq_add_dev() attempts to create a sysfs link
even when the target CPU is offline. Although guarded by a NULL
check on cpufreq_policy, this behavior is not strictly correct,
since offline CPUs shouldn't have their sysfs interface created.
This patch cleans up the logic to only add the sysfs link
when the CPU is online and cpufreq policy is properly initialized.
Signed-off-by: Zihuan Zhang <zzhwaxy.kernel@gmail.com>
---
drivers/cpufreq/cpufreq.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index d7426e1d8bdd..0a77892d366c 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1660,12 +1660,12 @@ static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif)
ret = cpufreq_online(cpu);
if (ret)
return ret;
- }
- /* Create sysfs link on CPU registration */
- policy = per_cpu(cpufreq_cpu_data, cpu);
- if (policy)
- add_cpu_dev_symlink(policy, cpu, dev);
+ /* Create sysfs link on CPU registration */
+ policy = per_cpu(cpufreq_cpu_data, cpu);
+ if (policy)
+ add_cpu_dev_symlink(policy, cpu, dev);
+ }
return 0;
}
--
2.34.1
next reply other threads:[~2025-07-21 15:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-21 15:36 Zihuan Zhang [this message]
2025-07-21 15:51 ` [PATCH v1] cpufreq: Avoid creating sysfs link for offline CPUs Rafael J. Wysocki
2025-07-21 16:02 ` 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=20250721153656.5103-1-zzhwaxy.kernel@gmail.com \
--to=zzhwaxy.kernel@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).