summaryrefslogtreecommitdiff
path: root/crypto
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@linaro.org>2023-10-30 12:02:59 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-01-25 15:44:40 -0800
commit95ad8b6879e2e49d02e3bfc0e1fb46421633fe2a (patch)
treeca8da4c82180b266140c24c04a3dc6611ca18673 /crypto
parent7f25cd51aa71711438a6c11fa638ba5aba61ed95 (diff)
crypto: rsa - add a check for allocation failure
[ Upstream commit d872ca165cb67112f2841ef9c37d51ef7e63d1e4 ] Static checkers insist that the mpi_alloc() allocation can fail so add a check to prevent a NULL dereference. Small allocations like this can't actually fail in current kernels, but adding a check is very simple and makes the static checkers happy. Fixes: 6637e11e4ad2 ("crypto: rsa - allow only odd e and restrict value in FIPS mode") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/rsa.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/crypto/rsa.c b/crypto/rsa.c
index c79613cdce6e..b9cd11fb7d36 100644
--- a/crypto/rsa.c
+++ b/crypto/rsa.c
@@ -220,6 +220,8 @@ static int rsa_check_exponent_fips(MPI e)
}
e_max = mpi_alloc(0);
+ if (!e_max)
+ return -ENOMEM;
mpi_set_bit(e_max, 256);
if (mpi_cmp(e, e_max) >= 0) {