ACK: [PATCH] cpu: cpufreq: avoid division by zero by initializing cpu_top_perf to 1
Alex Hung
alex.hung at canonical.com
Mon Jun 10 20:30:03 UTC 2019
On 2019-06-10 3:21 a.m., Colin King wrote:
> From: Colin Ian King <colin.king at 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 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 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 at canonical.com>
More information about the fwts-devel
mailing list