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
This commit is contained in:
Navdeep Parhar 2022-09-22 08:57:25 -07:00
parent f95c0bc89e
commit 02fac928ab

View File

@ -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;