Re: [PATCH v3] cpufreq: initialize policy rwsem before sysfs publication

From: Rafael J. Wysocki (Intel)

Date: Fri Sep 04 2026 - 11:50:22 EST


On Wed, Sep 2, 2026 at 6:27 AM Viresh Kumar <viresh.kumar@xxxxxxxxxx> wrote:
>
> 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>

Applied as 7.3-rc material, thanks!