]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
cpufreq: Init policy->rwsem before it may be possibly used
authorLifeng Zheng <zhenglifeng1@huawei.com>
Wed, 9 Jul 2025 10:41:43 +0000 (18:41 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 15 Aug 2025 10:08:43 +0000 (12:08 +0200)
commitf7e5ae0ddd12f8c8f5e0b7a6f7b61e251169ebe5
treebc5fbd45b82fbf3369754df77b07cf406308d25c
parent39a0d418b321283a5746d868c6f1ec85ad186324
cpufreq: Init policy->rwsem before it may be possibly used

[ Upstream commit d1378d1d7edb3a4c4935a44fe834ae135be03564 ]

In cpufreq_policy_put_kobj(), policy->rwsem is used. But in
cpufreq_policy_alloc(), if freq_qos_add_notifier() returns an error, error
path via err_kobj_remove or err_min_qos_notifier will be reached and
cpufreq_policy_put_kobj() will be called before policy->rwsem is
initialized. Thus, the calling of init_rwsem() should be moved to where
before these two error paths can be reached.

Fixes: 67d874c3b2c6 ("cpufreq: Register notifiers with the PM QoS framework")
Signed-off-by: Lifeng Zheng <zhenglifeng1@huawei.com>
Link: https://patch.msgid.link/20250709104145.2348017-3-zhenglifeng1@huawei.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/cpufreq/cpufreq.c