[PATCH] cpu: cpufreq: avoid division by zero
Colin King
colin.king at canonical.com
Mon May 6 23:41:18 UTC 2013
From: Colin Ian King <colin.king at canonical.com>
Coverity CID #997299, Division or modulo by zero (DIVIDE_BY_ZERO)
Avoid the very slim chance of a division by zero error.
Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
src/cpu/cpufreq/cpufreq.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/cpu/cpufreq/cpufreq.c b/src/cpu/cpufreq/cpufreq.c
index df52100..e115bbb 100644
--- a/src/cpu/cpufreq/cpufreq.c
+++ b/src/cpu/cpufreq/cpufreq.c
@@ -169,7 +169,10 @@ static int get_performance_repeat(
*retval = min;
break;
case GET_PERFORMANCE_AVG:
- *retval = cumulative / real_count;
+ if (real_count)
+ *retval = cumulative / real_count;
+ else
+ *retval = 0;
break;
default:
*retval = 0;
--
1.8.1.2
More information about the fwts-devel
mailing list