1
0
Fork 0

crypto: drbg - fix error return code in drbg_alloc_state()

commit e0664ebcea upstream.

Fix to return negative error code -ENOMEM from the kzalloc error handling
case instead of 0, as done elsewhere in this function.

Reported-by: Xiumei Mu <xmu@redhat.com>
Fixes: db07cd26ac ("crypto: drbg - add FIPS 140-2 CTRNG for noise source")
Cc: <stable@vger.kernel.org>
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Reviewed-by: Stephan Mueller <smueller@chronox.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5.4-rM2-2.2.x-imx-squashed
Wei Yongjun 2020-04-30 08:13:53 +00:00 committed by Greg Kroah-Hartman
parent 6ebdf342d4
commit 977b89e1ab
1 changed files with 3 additions and 1 deletions

View File

@ -1294,8 +1294,10 @@ static inline int drbg_alloc_state(struct drbg_state *drbg)
if (IS_ENABLED(CONFIG_CRYPTO_FIPS)) { if (IS_ENABLED(CONFIG_CRYPTO_FIPS)) {
drbg->prev = kzalloc(drbg_sec_strength(drbg->core->flags), drbg->prev = kzalloc(drbg_sec_strength(drbg->core->flags),
GFP_KERNEL); GFP_KERNEL);
if (!drbg->prev) if (!drbg->prev) {
ret = -ENOMEM;
goto fini; goto fini;
}
drbg->fips_primed = false; drbg->fips_primed = false;
} }