Skip to content

Commit d1378d1

Browse files
Lifeng Zhengrafaeljw
authored andcommitted
cpufreq: Init policy->rwsem before it may be possibly used
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: 67d874c ("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>
1 parent 2a6c727 commit d1378d1

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

drivers/cpufreq/cpufreq.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1281,6 +1281,8 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu)
12811281
goto err_free_real_cpus;
12821282
}
12831283

1284+
init_rwsem(&policy->rwsem);
1285+
12841286
freq_constraints_init(&policy->constraints);
12851287

12861288
policy->nb_min.notifier_call = cpufreq_notifier_min;
@@ -1303,7 +1305,6 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu)
13031305
}
13041306

13051307
INIT_LIST_HEAD(&policy->policy_list);
1306-
init_rwsem(&policy->rwsem);
13071308
spin_lock_init(&policy->transition_lock);
13081309
init_waitqueue_head(&policy->transition_wait);
13091310
INIT_WORK(&policy->update, handle_update);

0 commit comments

Comments
 (0)