diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c index 900a65156af9..d07d38e9faed 100644 --- a/drivers/cpufreq/cppc_cpufreq.c +++ b/drivers/cpufreq/cppc_cpufreq.c @@ -382,12 +382,12 @@ static int cppc_get_rate_from_fbctrs(struct cppc_cpudata *cpu, delta_delivered = get_delta(fb_ctrs_t1.delivered, fb_ctrs_t0.delivered); - /* Check to avoid divide-by zero */ - if (delta_reference || delta_delivered) + /* Check to avoid divide-by zero and invalid delivered_perf */ + if (!delta_reference || !delta_delivered) + delivered_perf = cpu->perf_ctrls.desired_perf; + else delivered_perf = (reference_perf * delta_delivered) / delta_reference; - else - delivered_perf = cpu->perf_ctrls.desired_perf; return cppc_cpufreq_perf_to_khz(cpu, delivered_perf); }