crypto: rsa - add a check for allocation failure
authorDan Carpenter <dan.carpenter@linaro.org>
Mon, 30 Oct 2023 09:02:59 +0000 (12:02 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Jan 2024 23:35:15 +0000 (15:35 -0800)
commit2831f4d3bfa68e64c5f83e96688be779c87b3511
tree09bd1d167900cf129a4abe7369c11bddca4370f6
parent089ff0eeb78525c6bbd8a157cd7566cfb14720d3
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>
crypto/rsa.c