Skip to contentSkip to conversation

In cpufreq, check for a driver before use

PATCH New Mark Langsdorf 1 participant 1 message Oct 22, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 In cpufreq, check for a driver before use

The current cpufreq driver code assumes that a driver was registered before cpufreq_add_cpu() is called. If the driver was not registered or failed registration, cpufreq_add_cpu() crashes.

Test to make sure that cpufreq_driver isn't NULL.

xen/drivers/cpufreq/cpufreq.c +3 -0
diff -r d7d7f978d704 xen/drivers/cpufreq/cpufreq.c
@@ -142,6 +142,9 @@
         !(perf->init & XEN_PX_INIT) ||
         !cpu_online(cpu))
         return -EINVAL;
+
+    if (!cpufreq_driver)
+        return 0;
 
     if (cpufreq_cpu_policy[cpu])
         return 0;