Skip to contentSkip to conversation

add bounds checking to cpufreq_stats.c from upstream

PATCH New Mark Langsdorf 1 participant 1 message Dec 13, 2007 CPU frequency scaling framework

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

-Mark Langsdorf
Operating System Research Center
AMD

drivers/cpufreq/cpufreq_stats.c +3 -0
diff -r cd744c5ec950 drivers/cpufreq/cpufreq_stats.c
@@ -292,6 +292,9 @@ cpufreq_stat_notifier_trans (struct noti
 	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