[PATCH 06/10] cpu: cpufreq: avoid division by zero ob cpu_top_speed

Colin King colin.king at canonical.com
Thu May 1 14:01:17 UTC 2014


From: Colin Ian King <colin.king at canonical.com>

Coverity Scan detected a potential division by zero. This is highly
unlikely, but to be safe, initialize cpu_top_speed to 1 to avoid
this every happening.

Signed-off-by: Colin Ian King <colin.king at canonical.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 993acb4..cecd083 100644
--- a/src/cpu/cpufreq/cpufreq.c
+++ b/src/cpu/cpufreq/cpufreq.c
@@ -268,7 +268,7 @@ static void do_cpu(fwts_framework *fw, const int cpu)
 	int i, speedcount;
 	static int warned = 0;
 	bool warned_PSS = false;
-	uint64_t cpu_top_speed = 0;
+	uint64_t cpu_top_speed = 1;
 	int claimed_hz_too_low = 0;
 	int bios_limit_too_low = 0;
 	const uint32_t claimed_hz = get_claimed_hz(cpu);
-- 
2.0.0.rc0




More information about the fwts-devel mailing list