Re: [PATCH v3] cpufreq: initialize policy rwsem before sysfs publication
From: Viresh Kumar
Date: Wed Sep 02 2026 - 00:27:21 EST
On 02-09-26, 12:19, 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@xxxxxxxxxxxxxxx
> Link: https://lore.kernel.org/all/20260830155301.2713780-1-runyu.xiao@xxxxxxxxxx/
> Assisted-by: Codex:GPT-5
> Reviewed-by: Zhongqiu Han <zhongqiu.han@xxxxxxxxxxxxxxxx>
> Signed-off-by: Runyu Xiao <runyu.xiao@xxxxxxxxxx>
Acked-by: Viresh Kumar <viresh.kumar@xxxxxxxxxx>
--
viresh