* [PATCH 1/1] cpufreq: prevent NULL dereference in cpufreq_online
@ 2025-02-05 18:13 Aboorva Devarajan
2025-02-05 20:04 ` Rafael J. Wysocki
0 siblings, 1 reply; 2+ messages in thread
From: Aboorva Devarajan @ 2025-02-05 18:13 UTC (permalink / raw)
To: rafael, viresh.kumar, zhenglifeng1
Cc: linux-pm, linux-kernel, gautam, aboorvad
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: dd016f379ebc ("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>
---
drivers/cpufreq/cpufreq.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index e0048856ecee..30ffbddc7ece 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1571,7 +1571,8 @@ static int cpufreq_online(unsigned int cpu)
policy->cdev = of_cpufreq_cooling_register(policy);
/* Let the per-policy boost flag mirror the cpufreq_driver boost during init */
- if (policy->boost_enabled != cpufreq_boost_enabled()) {
+ if (cpufreq_driver->set_boost &&
+ policy->boost_enabled != cpufreq_boost_enabled()) {
policy->boost_enabled = cpufreq_boost_enabled();
ret = cpufreq_driver->set_boost(policy, policy->boost_enabled);
if (ret) {
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH 1/1] cpufreq: prevent NULL dereference in cpufreq_online
2025-02-05 18:13 [PATCH 1/1] cpufreq: prevent NULL dereference in cpufreq_online Aboorva Devarajan
@ 2025-02-05 20:04 ` Rafael J. Wysocki
0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2025-02-05 20:04 UTC (permalink / raw)
To: Aboorva Devarajan
Cc: rafael, viresh.kumar, zhenglifeng1, linux-pm, linux-kernel, gautam
On Wed, Feb 5, 2025 at 7:14 PM Aboorva Devarajan <aboorvad@linux.ibm.com> wrote:
>
> 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: dd016f379ebc ("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>
> ---
> drivers/cpufreq/cpufreq.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index e0048856ecee..30ffbddc7ece 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -1571,7 +1571,8 @@ static int cpufreq_online(unsigned int cpu)
> policy->cdev = of_cpufreq_cooling_register(policy);
>
> /* Let the per-policy boost flag mirror the cpufreq_driver boost during init */
> - if (policy->boost_enabled != cpufreq_boost_enabled()) {
> + if (cpufreq_driver->set_boost &&
> + policy->boost_enabled != cpufreq_boost_enabled()) {
> policy->boost_enabled = cpufreq_boost_enabled();
> ret = cpufreq_driver->set_boost(policy, policy->boost_enabled);
> if (ret) {
> --
Applied as 6.14-rc material, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-02-05 20:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-05 18:13 [PATCH 1/1] cpufreq: prevent NULL dereference in cpufreq_online Aboorva Devarajan
2025-02-05 20:04 ` Rafael J. Wysocki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®