Message ID | d870c278-3f0e-4386-a58d-c9e2c97a7c6c@moroto.mountain |
---|---|
State | Accepted |
Commit | d872ca165cb67112f2841ef9c37d51ef7e63d1e4 |
Headers | show |
Series | crypto: rsa - add a check for allocation failure | expand |
On Mon, Oct 30, 2023 at 12:02:59PM +0300, Dan Carpenter wrote: > 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> > --- > crypto/rsa.c | 2 ++ > 1 file changed, 2 insertions(+) Patch applied. Thanks.
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) {
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> --- crypto/rsa.c | 2 ++ 1 file changed, 2 insertions(+)