]> xenbits.xensource.com Git - legacy/linux-2.6.18-xen.git/commitdiff
cpufreq: add bounds checking to cpufreq_stats.c from upstream
authorKeir Fraser <keir.fraser@citrix.com>
Fri, 14 Dec 2007 11:28:40 +0000 (11:28 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Fri, 14 Dec 2007 11:28:40 +0000 (11:28 +0000)
The cpufreq_stats.c will attempt to use an error return value as
an index to an array, causing the kernel to oops.  Stop that by
doing bounds checking.

This is a backport of upstream code.

Signed-off-by: Mark Langsdorf <mark.langsdorf@amd.com>
drivers/cpufreq/cpufreq_stats.c

index c2ecc599dc5f388a67e5f812a949424ee3db8d6d..bb2125c6e09f9637d1bcc5a8aeb1ef8f2e05ede6 100644 (file)
@@ -292,6 +292,9 @@ cpufreq_stat_notifier_trans (struct notifier_block *nb, unsigned long val,
        if (old_index == new_index)
                return 0;
 
+        if ((old_index < 0) || (new_index < 0))
+                return 0;
+
        spin_lock(&cpufreq_stats_lock);
        stat->last_index = new_index;
 #ifdef CONFIG_CPU_FREQ_STAT_DETAILS