]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
net/mlx4_en: Prevent potential integer overflow calculating Hz
authorDan Carpenter <dan.carpenter@linaro.org>
Wed, 28 May 2025 08:11:09 +0000 (11:11 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 27 Jun 2025 10:07:17 +0000 (11:07 +0100)
commit12418da8e784749e24d68b48b8be8bbbf989eaac
treeb70465787a89823ffe88e7ade3631d8ebbff38b4
parent4e2208307e91a2ae7287e29f37511dc87e9164f4
net/mlx4_en: Prevent potential integer overflow calculating Hz

[ Upstream commit 54d34165b4f786d7fea8412a18fb4a54c1eab623 ]

The "freq" variable is in terms of MHz and "max_val_cycles" is in terms
of Hz.  The fact that "max_val_cycles" is a u64 suggests that support
for high frequency is intended but the "freq_khz * 1000" would overflow
the u32 type if we went above 4GHz.  Use unsigned long long type for the
mutliplication to prevent that.

Fixes: 31c128b66e5b ("net/mlx4_en: Choose time-stamping shift value according to HW frequency")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/aDbFHe19juIJKjsb@stanley.mountain
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/mellanox/mlx4/en_clock.c