]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
crypto: qat - avoid division by zero
authorAdam Guerin <adam.guerin@intel.com>
Fri, 16 Feb 2024 15:19:57 +0000 (15:19 +0000)
committerSasha Levin <sashal@kernel.org>
Tue, 26 Mar 2024 22:19:51 +0000 (18:19 -0400)
commitf5aa20882eea6932e364615621de97006a6cb57e
tree431108d1b9e9520d2b9dcbcc408846709051bbc1
parent6a28ba59e4771483d1e85ca11ded5944071406af
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>
drivers/crypto/intel/qat/qat_common/adf_clock.c