git: 02fac928ab68 - main - cxgbe(4): Fix potential integer overflow in t4_tstmp_to_ns.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 22 Sep 2022 16:50:10 UTC
The branch main has been updated by np:
URL: https://cgit.FreeBSD.org/src/commit/?id=02fac928ab687607786801cdf33f100c70cc6a2e
commit 02fac928ab687607786801cdf33f100c70cc6a2e
Author: Navdeep Parhar <np@FreeBSD.org>
AuthorDate: 2022-09-22 15:57:25 +0000
Commit: Navdeep Parhar <np@FreeBSD.org>
CommitDate: 2022-09-22 16:47:11 +0000
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 0dbd4e92a684..e0b73ccd8b51 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;