crypto: rsa - add a check for allocation failure

JIRA: https://issues.redhat.com/browse/RHEL-24869
Upstream Status: merged into the linux.git

commit d872ca165cb67112f2841ef9c37d51ef7e63d1e4
Author: Dan Carpenter <dan.carpenter@linaro.org>
Date:   Mon Oct 30 12:02:59 2023 +0300

    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: 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: Vladis Dronov <vdronov@redhat.com>
This commit is contained in:
Vladis Dronov 2024-02-15 19:59:15 +01:00
parent b475cb2a6f
commit 0319ea12e1
1 changed files with 2 additions and 0 deletions

View File

@ -172,6 +172,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) {