From 02fac928ab687607786801cdf33f100c70cc6a2e Mon Sep 17 00:00:00 2001 From: Navdeep Parhar Date: Thu, 22 Sep 2022 08:57:25 -0700 Subject: [PATCH] cxgbe(4): Fix potential integer overflow in t4_tstmp_to_ns. Coverity flagged this in its latest run but it is not a problem in practice as the card's core clock would have to be > 4.2GHz for any overflow to occur. CID 1498303: Integer handling issues (OVERFLOW_BEFORE_WIDEN) Potentially overflowing expression "sc->params.vpd.cclk * 1000U" with type "unsigned int" (32 bits, unsigned) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type "uint64_t" (64 bits, unsigned). Reported by: Coverity Scan (CID 1498303) Sponsored by: Chelsio Communications --- sys/dev/cxgbe/t4_sge.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c index 0dbd4e92a68..e0b73ccd8b5 100644 --- a/sys/dev/cxgbe/t4_sge.c +++ b/sys/dev/cxgbe/t4_sge.c @@ -1562,7 +1562,7 @@ t4_tstmp_to_ns(struct adapter *sc, uint64_t lf) * Note that vpd.cclk is in khz, we need it in raw hz so * convert to hz. */ - cclk = sc->params.vpd.cclk * 1000; + cclk = (uint64_t)sc->params.vpd.cclk * 1000; hw_clocks = hw_tstmp - dcur.hw_prev; tstmp_sec = hw_clocks / cclk; tstmp_nsec = hw_clocks % cclk;