Skip to content
Commit 7b749137 authored by Alexis Lothoré's avatar Alexis Lothoré Committed by Paolo Abeni
Browse files

net: stmmac: fix multiplication overflow when reading timestamp



The current way of reading a timestamp snapshot in stmmac can lead to
integer overflow, as the computation is done on 32 bits. The issue has
been observed on a dwmac-socfpga platform returning chaotic timestamp
values due to this overflow. The corresponding multiplication is done
with a MUL instruction, which returns 32 bit values. Explicitly casting
the value to 64 bits replaced the MUL with a UMLAL, which computes and
returns the result on 64 bits, and so returns correctly the timestamps.

Prevent this overflow by explicitly casting the intermediate value to
u64 to make sure that the whole computation is made on u64. While at it,
apply the same cast on the other dwmac variant (GMAC4) method for
snapshot retrieval.

Fixes: 477c3e1f ("net: stmmac: Introduce dwmac1000 timestamping operations")
Signed-off-by: default avatarAlexis Lothoré <alexis.lothore@bootlin.com>
Reviewed-by: default avatarMaxime Chevallier <maxime.chevallier@bootlin.com>
Link: https://patch.msgid.link/20250423-stmmac_ts-v2-2-e2cf2bbd61b1@bootlin.com


Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 73fa4597
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment