[PATCH] arm64: topology: fix possible overflow in amu_fie_setup()
Sergey Shtylyov
s.shtylyov at omp.ru
Fri Sep 16 13:17:07 PDT 2022
cpufreq_get_hw_max_freq() returns max frequency in kHz as *unsigned int*,
while freq_inv_set_max_ratio() gets passed this frequency in Hz as 'u64'.
Multiplying max frequency by 1000 can potentially result in overflow --
multiplying by 1000ULL instead should avoid that...
Found by Linux Verification Center (linuxtesting.org) with the SVACE static
analysis tool.
Fixes: cd0ed03a8903 ("arm64: use activity monitors for frequency invariance")
Signed-off-by: Sergey Shtylyov <s.shtylyov at omp.ru>
---
The patch is against the 'for-next/fixes' branch of the ARM64 repo...
arch/arm64/kernel/topology.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: linux/arch/arm64/kernel/topology.c
===================================================================
--- linux.orig/arch/arm64/kernel/topology.c
+++ linux/arch/arm64/kernel/topology.c
@@ -237,7 +237,7 @@ static void amu_fie_setup(const struct c
for_each_cpu(cpu, cpus) {
if (!freq_counters_valid(cpu) ||
freq_inv_set_max_ratio(cpu,
- cpufreq_get_hw_max_freq(cpu) * 1000,
+ cpufreq_get_hw_max_freq(cpu) * 1000ULL,
arch_timer_get_rate()))
return;
}
More information about the linux-arm-kernel
mailing list