Skip to content

Commit 96e37ce

Browse files
Dan CarpenterPlaidCat
authored andcommitted
crypto: rsa - add a check for allocation failure
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: 6637e11 ("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>
1 parent 6bd58da commit 96e37ce

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

crypto/rsa.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ static int rsa_check_exponent_fips(MPI e)
172172
}
173173

174174
e_max = mpi_alloc(0);
175+
if (!e_max)
176+
return -ENOMEM;
175177
mpi_set_bit(e_max, 256);
176178

177179
if (mpi_cmp(e, e_max) >= 0) {

0 commit comments

Comments
 (0)