提交 8b849f6e 编写于 作者: S Sergey Shtylyov 提交者: Jialin Zhang

arm64: topology: fix possible overflow in amu_fie_setup()

stable inclusion
from stable-v5.10.150
commit 904f881b57360cf85de962d84d8614d94431f60e
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I6D0XA

Reference:  https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=904f881b57360cf85de962d84d8614d94431f60e

--------------------------------

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: cd0ed03a ("arm64: use activity monitors for frequency invariance")
Signed-off-by: NSergey Shtylyov <s.shtylyov@omp.ru>
Link: https://lore.kernel.org/r/01493d64-2bce-d968-86dc-11a122a9c07d@omp.ruSigned-off-by: NWill Deacon <will@kernel.org>

conflicts:
	arch/arm64/kernel/topology.c
Signed-off-by: NLin Yujun <linyujun809@huawei.com>
Reviewed-by: NZhang Jianhua <chris.zjh@huawei.com>
Signed-off-by: NJialin Zhang <zhangjialin11@huawei.com>
上级 b2c428b7
......@@ -252,7 +252,7 @@ static int __init init_amu_fie(void)
for_each_present_cpu(cpu) {
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()))
continue;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册