]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
cpufreq/longhaul: handle NULL policy in longhaul_exit
authorDennis Beier <nanovim@gmail.com>
Sat, 30 Aug 2025 14:43:59 +0000 (16:43 +0200)
committerViresh Kumar <viresh.kumar@linaro.org>
Mon, 1 Sep 2025 05:20:28 +0000 (10:50 +0530)
longhaul_exit() was calling cpufreq_cpu_get(0) without checking
for a NULL policy pointer. On some systems, this could lead to a
NULL dereference and a kernel warning or panic.

This patch adds a check using unlikely() and returns early if the
policy is NULL.

Bugzilla: #219962

Signed-off-by: Dennis Beier <nanovim@gmail.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
drivers/cpufreq/longhaul.c

index ba0e08c8486a6efd84152e5735d7a53c1314ce79..49e76b44468aa301e584dc10e8abf10097096280 100644 (file)
@@ -953,6 +953,9 @@ static void __exit longhaul_exit(void)
        struct cpufreq_policy *policy = cpufreq_cpu_get(0);
        int i;
 
+       if (unlikely(!policy))
+               return;
+
        for (i = 0; i < numscales; i++) {
                if (mults[i] == maxmult) {
                        struct cpufreq_freqs freqs;