From: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>
To: Runyu Xiao <runyu.xiao@seu.edu.cn>,
"Rafael J . Wysocki" <rafael@kernel.org>
Cc: Viresh Kumar <viresh.kumar@linaro.org>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org, Jianhao Xu <jianhao.xu@seu.edu.cn>,
zhongqiu.han@oss.qualcomm.com
Subject: Re: [PATCH v2] cpufreq: initialize policy rwsem before sysfs publication
Date: Tue, 1 Sep 2026 21:07:32 +0800 [thread overview]
Message-ID: <36d2a431-a1c3-478e-a001-936d25bcb9e1@oss.qualcomm.com> (raw)
In-Reply-To: <20260901121950.3279176-1-runyu.xiao@seu.edu.cn>
On 9/1/2026 8:19 PM, Runyu Xiao wrote:
> cpufreq_policy_alloc() initializes policy->rwsem after
> kobject_init_and_add() has created the policy sysfs directory and its
> default attributes. A sysfs access can therefore reach a policy callback
> before the semaphore has been initialized.
>
> Initialize policy->rwsem before publishing the policy kobject so sysfs
> callbacks always see an initialized semaphore.
>
> Fixes: 2fc3384dc75b ("cpufreq: Initialize policy->kobj while allocating policy")
> Cc: stable@vger.kernel.org
> Link: https://lore.kernel.org/all/20260830155301.2713780-1-runyu.xiao@seu.edu.cn/
Nit: It points to V1 Link, but should be okay according by https://
docs.kernel.org/process/submitting-patches.html#describe-your-changes
> Signed-off-by: Runyu Xiao <runyu.xiao@seu.edu.cn>
> Assisted-by: Codex:GPT-5
Nit: Sob tag should always be the last tag.
Reviewed-by: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>
>
> ---
> v2:
> - Correct the Fixes tag to the commit that introduced policy kobject publication.
> ---
> drivers/cpufreq/cpufreq.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 0d0df986f..9efbf5b17 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -1258,6 +1258,8 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu)
> if (!zalloc_cpumask_var(&policy->real_cpus, GFP_KERNEL))
> goto err_free_rcpumask;
>
> + init_rwsem(&policy->rwsem);
> +
> init_completion(&policy->kobj_unregister);
> ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq,
> cpufreq_global_kobject, "policy%u", cpu);
> @@ -1272,8 +1274,6 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu)
> goto err_free_real_cpus;
> }
>
> - init_rwsem(&policy->rwsem);
> -
> freq_constraints_init(&policy->constraints);
>
> policy->nb_min.notifier_call = cpufreq_notifier_min;
--
Thx and BRs,
Zhongqiu Han
prev parent reply other threads:[~2026-09-01 13:07 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-30 15:53 [PATCH] cpufreq: initialize policy rwsem before sysfs publication Runyu Xiao
2026-08-31 5:29 ` Viresh Kumar
2026-08-31 12:13 ` Zhongqiu Han
2026-09-01 4:50 ` Viresh Kumar
2026-09-02 4:19 ` [PATCH v3] " Runyu Xiao
2026-09-02 4:27 ` Viresh Kumar
2026-09-04 15:06 ` Rafael J. Wysocki (Intel)
2026-09-01 12:19 ` [PATCH v2] " Runyu Xiao
2026-09-01 13:07 ` Zhongqiu Han [this message]
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=36d2a431-a1c3-478e-a001-936d25bcb9e1@oss.qualcomm.com \
--to=zhongqiu.han@oss.qualcomm.com \
--cc=jianhao.xu@seu.edu.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=runyu.xiao@seu.edu.cn \
--cc=stable@vger.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