]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: stmmac: ptp: fix potentially overflowing expression
authorXiaoliang Yang <xiaoliang.yang_1@nxp.com>
Thu, 23 Dec 2021 07:39:28 +0000 (15:39 +0800)
committerJakub Kicinski <kuba@kernel.org>
Thu, 23 Dec 2021 17:45:55 +0000 (09:45 -0800)
Convert the u32 variable to type u64 in a context where expression of
type u64 is required to avoid potential overflow.

Fixes: cc36a402707e ("net: stmmac: ptp: update tas basetime after ptp adjust")
Signed-off-by: Xiaoliang Yang <xiaoliang.yang_1@nxp.com>
Link: https://lore.kernel.org/r/20211223073928.37371-1-xiaoliang.yang_1@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c

index 580cc035536bd8893ffc0daca0c51231e3969ae6..be9b58b2abf9bec07743969f75ca2e902acff7b6 100644 (file)
@@ -102,7 +102,7 @@ static int stmmac_adjust_time(struct ptp_clock_info *ptp, s64 delta)
                time.tv_nsec = priv->plat->est->btr_reserve[0];
                time.tv_sec = priv->plat->est->btr_reserve[1];
                basetime = timespec64_to_ktime(time);
-               cycle_time = priv->plat->est->ctr[1] * NSEC_PER_SEC +
+               cycle_time = (u64)priv->plat->est->ctr[1] * NSEC_PER_SEC +
                             priv->plat->est->ctr[0];
                time = stmmac_calc_tas_basetime(basetime,
                                                current_time_ns,