diff options
author | Adam Guerin <adam.guerin@intel.com> | 2024-02-16 15:19:57 +0000 |
---|---|---|
committer | Sasha Levin <sashal@kernel.org> | 2024-03-26 18:19:51 -0400 |
commit | f5aa20882eea6932e364615621de97006a6cb57e (patch) | |
tree | 431108d1b9e9520d2b9dcbcc408846709051bbc1 /drivers | |
parent | 6a28ba59e4771483d1e85ca11ded5944071406af (diff) | |
download | linux-stable-f5aa20882eea6932e364615621de97006a6cb57e.tar.gz linux-stable-f5aa20882eea6932e364615621de97006a6cb57e.tar.bz2 linux-stable-f5aa20882eea6932e364615621de97006a6cb57e.zip |
crypto: qat - avoid division by zero
[ Upstream commit f99fb7d660f7c818105803f1f1915396a14d18ad ]
Check if delta_us is not zero and return -EINVAL if it is.
delta_us is unlikely to be zero as there is a sleep between the reads of
the two timestamps.
This is to fix the following warning when compiling the QAT driver
using clang scan-build:
drivers/crypto/intel/qat/qat_common/adf_clock.c:87:9: warning: Division by zero [core.DivideZero]
87 | temp = DIV_ROUND_CLOSEST_ULL(temp, delta_us);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fixes: e2980ba57e79 ("crypto: qat - add measure clock frequency")
Signed-off-by: Adam Guerin <adam.guerin@intel.com>
Reviewed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/crypto/intel/qat/qat_common/adf_clock.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/crypto/intel/qat/qat_common/adf_clock.c b/drivers/crypto/intel/qat/qat_common/adf_clock.c index dc0778691eb0..eae44969dc84 100644 --- a/drivers/crypto/intel/qat/qat_common/adf_clock.c +++ b/drivers/crypto/intel/qat/qat_common/adf_clock.c @@ -82,6 +82,9 @@ static int measure_clock(struct adf_accel_dev *accel_dev, u32 *frequency) } delta_us = timespec_to_us(&ts3) - timespec_to_us(&ts1); + if (!delta_us) + return -EINVAL; + temp = (timestamp2 - timestamp1) * ME_CLK_DIVIDER * 10; temp = DIV_ROUND_CLOSEST_ULL(temp, delta_us); /* |