xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/cpufreq: check array index before use
@ 2010-07-06 15:51 Jan Beulich
  0 siblings, 0 replies; only message in thread
From: Jan Beulich @ 2010-07-06 15:51 UTC (permalink / raw)
  To: xen-devel@lists.xensource.com

[-- Attachment #1: Type: text/plain, Size: 711 bytes --]

... rather than after.

Signed-off-by: Jan Beulich <jbeulich@novell.com>

--- 2010-06-15.orig/xen/arch/x86/acpi/cpufreq/cpufreq.c	2010-07-06 16:08:59.000000000 +0200
+++ 2010-06-15/xen/arch/x86/acpi/cpufreq/cpufreq.c	2010-07-06 16:11:48.000000000 +0200
@@ -210,9 +210,11 @@ static u32 get_cur_val(cpumask_t mask)
 
     if (!cpu_isset(cpu, mask))
         cpu = first_cpu(mask);
-    policy = cpufreq_cpu_policy[cpu];
+    if (cpu >= NR_CPUS)
+        return 0;
 
-    if (cpu >= NR_CPUS || !policy || !drv_data[policy->cpu])
+    policy = cpufreq_cpu_policy[cpu];
+    if (!policy || !drv_data[policy->cpu])
         return 0;    
 
     switch (drv_data[policy->cpu]->cpu_feature) {




[-- Attachment #2: x86-cpufreq-cpu-check.patch --]
[-- Type: text/plain, Size: 705 bytes --]

... rather than after.

Signed-off-by: Jan Beulich <jbeulich@novell.com>

--- 2010-06-15.orig/xen/arch/x86/acpi/cpufreq/cpufreq.c	2010-07-06 16:08:59.000000000 +0200
+++ 2010-06-15/xen/arch/x86/acpi/cpufreq/cpufreq.c	2010-07-06 16:11:48.000000000 +0200
@@ -210,9 +210,11 @@ static u32 get_cur_val(cpumask_t mask)
 
     if (!cpu_isset(cpu, mask))
         cpu = first_cpu(mask);
-    policy = cpufreq_cpu_policy[cpu];
+    if (cpu >= NR_CPUS)
+        return 0;
 
-    if (cpu >= NR_CPUS || !policy || !drv_data[policy->cpu])
+    policy = cpufreq_cpu_policy[cpu];
+    if (!policy || !drv_data[policy->cpu])
         return 0;    
 
     switch (drv_data[policy->cpu]->cpu_feature) {

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-07-06 15:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-06 15:51 [PATCH] x86/cpufreq: check array index before use Jan Beulich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).