From: Ionela Voinescu Date: Tue, 1 Sep 2020 20:55:45 +0000 (+0100) Subject: arch_topology: validate input frequencies to arch_set_freq_scale() X-Git-Tag: v5.10.7~1444^2~3^2~11^2~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0a10d3fe3e5c601031676e81b41fb2977650b4d4;p=platform%2Fkernel%2Flinux-rpi.git arch_topology: validate input frequencies to arch_set_freq_scale() The current frequency passed to arch_set_freq_scale() could end up being 0, signaling an error in setting a new frequency. Also, if the maximum frequency in 0, this will result in a division by 0 error. Therefore, validate these input values before using them for the setting of the frequency scale factor. Signed-off-by: Ionela Voinescu Acked-by: Viresh Kumar Reviewed-by: Sudeep Holla Signed-off-by: Rafael J. Wysocki --- diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index 75f72d6..42a08ef 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -33,6 +33,9 @@ void arch_set_freq_scale(struct cpumask *cpus, unsigned long cur_freq, unsigned long scale; int i; + if (WARN_ON_ONCE(!cur_freq || !max_freq)) + return; + /* * If the use of counters for FIE is enabled, just return as we don't * want to update the scale factor with information from CPUFREQ.