arm64: topology: fix possible overflow in amu_fie_setup()
PATCH 1/1 arm64: topology: fix possible overflow in amu_fie_setup()
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.
---
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(-)
arch/arm64/kernel/topology.c +1 -1
@@ -237,7 +237,7 @@ static void amu_fie_setup(const struct cfor_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 ; }
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 9 lines · Sergey Shtylyov
cpufreq_get_hw_max_freq()returns max frequency in kHz as *unsigned int*, whilefreq_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.
[...]
Applied to arm64 (for-next/fixes), thanks!
[1/1] arm64: topology: fix possible overflow in amu_fie_setup()
https://git.kernel.org/arm64/c/d4955c0ad77d
Cheers,
Signature · 10 lines
Will https://fixes.arm64.dev https://next.arm64.dev https://will.arm64.dev _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel