Skip to content

Commit 0813fd2

Browse files
AboorvaDevarajanrafaeljw
authored andcommitted
cpufreq: prevent NULL dereference in cpufreq_online()
Ensure cpufreq_driver->set_boost is non-NULL before using it in cpufreq_online() to prevent a potential NULL pointer dereference. Reported-by: Gautam Menghani <gautam@linux.ibm.com> Closes: https://lore.kernel.org/all/c9e56c5f54cc33338762c94e9bed7b5a0d5de812.camel@linux.ibm.com/ Fixes: dd016f3 ("cpufreq: Introduce a more generic way to set default per-policy boost flag") Suggested-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Aboorva Devarajan <aboorvad@linux.ibm.com> Link: https://patch.msgid.link/20250205181347.2079272-1-aboorvad@linux.ibm.com [ rjw: Minor edits in the subject and changelog ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 90508a1 commit 0813fd2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/cpufreq/cpufreq.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1571,7 +1571,8 @@ static int cpufreq_online(unsigned int cpu)
15711571
policy->cdev = of_cpufreq_cooling_register(policy);
15721572

15731573
/* Let the per-policy boost flag mirror the cpufreq_driver boost during init */
1574-
if (policy->boost_enabled != cpufreq_boost_enabled()) {
1574+
if (cpufreq_driver->set_boost &&
1575+
policy->boost_enabled != cpufreq_boost_enabled()) {
15751576
policy->boost_enabled = cpufreq_boost_enabled();
15761577
ret = cpufreq_driver->set_boost(policy, policy->boost_enabled);
15771578
if (ret) {

0 commit comments

Comments
 (0)