Message ID | 20190610102146.27721-1-colin.king@canonical.com |
---|---|
State | Accepted |
Headers | show |
Series |
|
Related | show |
On 2019-06-10 3:21 a.m., Colin King wrote: > From: Colin Ian King <colin.king@canonical.com> > > There is a potential division by zero if no cpu frequencies are found > when cpu_top_perf is initialized as zero. A simple fix is to initialize > it to 1. > > Addresses-Coverity: ("Division or modulo by zero") > Signed-off-by: Colin Ian King <colin.king@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 60101f29..8c8870c0 100644 > --- a/src/cpu/cpufreq/cpufreq.c > +++ b/src/cpu/cpufreq/cpufreq.c > @@ -279,7 +279,7 @@ static uint64_t get_bios_limit(struct cpu *cpu) > static int test_one_cpu_performance(fwts_framework *fw, struct cpu *cpu, > int cpu_idx, int n_online_cpus) > { > - uint64_t cpu_top_perf = 0; > + uint64_t cpu_top_perf = 1; > int i; > > for (i = 0; i < cpu->n_freqs; i++) { > Acked-by: Alex Hung <alex.hung@canonical.com>
On 6/10/19 6:21 PM, Colin King wrote: > From: Colin Ian King <colin.king@canonical.com> > > There is a potential division by zero if no cpu frequencies are found > when cpu_top_perf is initialized as zero. A simple fix is to initialize > it to 1. > > Addresses-Coverity: ("Division or modulo by zero") > Signed-off-by: Colin Ian King <colin.king@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 60101f29..8c8870c0 100644 > --- a/src/cpu/cpufreq/cpufreq.c > +++ b/src/cpu/cpufreq/cpufreq.c > @@ -279,7 +279,7 @@ static uint64_t get_bios_limit(struct cpu *cpu) > static int test_one_cpu_performance(fwts_framework *fw, struct cpu *cpu, > int cpu_idx, int n_online_cpus) > { > - uint64_t cpu_top_perf = 0; > + uint64_t cpu_top_perf = 1; > int i; > > for (i = 0; i < cpu->n_freqs; i++) { Acked-by: Ivan Hu <ivan.hu@canonical.com>
diff --git a/src/cpu/cpufreq/cpufreq.c b/src/cpu/cpufreq/cpufreq.c index 60101f29..8c8870c0 100644 --- a/src/cpu/cpufreq/cpufreq.c +++ b/src/cpu/cpufreq/cpufreq.c @@ -279,7 +279,7 @@ static uint64_t get_bios_limit(struct cpu *cpu) static int test_one_cpu_performance(fwts_framework *fw, struct cpu *cpu, int cpu_idx, int n_online_cpus) { - uint64_t cpu_top_perf = 0; + uint64_t cpu_top_perf = 1; int i; for (i = 0; i < cpu->n_freqs; i++) {