From: Keir Fraser Date: Fri, 14 Dec 2007 11:28:40 +0000 (+0000) Subject: cpufreq: add bounds checking to cpufreq_stats.c from upstream X-Git-Tag: xen-3.2.0~46 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=eb709ee510aac194d953b90e97bb2749105c7e96;p=legacy%2Flinux-2.6.18-xen.git cpufreq: add bounds checking to cpufreq_stats.c from upstream 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 --- diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index c2ecc599..bb2125c6 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/drivers/cpufreq/cpufreq_stats.c @@ -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