[PATCH] cpu/cpufreq: Iterate over the correct number of CPUs in _test_sw_any

Ricardo Neri ricardo.neri-calderon at linux.intel.com
Fri Jul 24 00:05:48 UTC 2015


cpu_test_sw_any goes into a loop to set the frequency of all the
available CPUs. However, the loop iterates beyond the limits of the
CPUs array. Given that functions such as cpu_set_lowest_frequency
derreference members of struct cpu, iterating beyond the limits of the
array might cause segmentation faults.

Signed-off-by: Ricardo Neri <ricardo.neri-calderon at linux.intel.com>
---
 src/cpu/cpufreq/cpufreq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/cpu/cpufreq/cpufreq.c b/src/cpu/cpufreq/cpufreq.c
index 40f6a30..35812f4 100644
--- a/src/cpu/cpufreq/cpufreq.c
+++ b/src/cpu/cpufreq/cpufreq.c
@@ -507,7 +507,7 @@ static int cpufreq_test_sw_any(fwts_framework *fw)
 
 	ok = true;
 
-	for (i = 0; i <= num_cpus; i++) {
+	for (i = 0; i < num_cpus; i++) {
 		struct cpu *cpu = &cpus[i];
 
 		if (!cpu->online)
-- 
1.9.1




More information about the fwts-devel mailing list