summaryrefslogtreecommitdiff
path: root/crypto
diff options
context:
space:
mode:
authorWei Yongjun <weiyongjun1@huawei.com>2020-04-30 08:13:53 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-06-17 16:40:31 +0200
commit977b89e1aba0c7020555d1272e0e7d1140d8e1eb (patch)
tree4775dc983eda9821a432174edd2f525184a88180 /crypto
parent6ebdf342d4c79edbd05ad6938855c864d535a297 (diff)
crypto: drbg - fix error return code in drbg_alloc_state()
commit e0664ebcea6ac5e16da703409fb4bd61f8cd37d9 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: db07cd26ac6a ("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>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/drbg.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/crypto/drbg.c b/crypto/drbg.c
index b6929eb5f565..04379ca624cd 100644
--- a/crypto/drbg.c
+++ b/crypto/drbg.c
@@ -1294,8 +1294,10 @@ static inline int drbg_alloc_state(struct drbg_state *drbg)
if (IS_ENABLED(CONFIG_CRYPTO_FIPS)) {
drbg->prev = kzalloc(drbg_sec_strength(drbg->core->flags),
GFP_KERNEL);
- if (!drbg->prev)
+ if (!drbg->prev) {
+ ret = -ENOMEM;
goto fini;
+ }
drbg->fips_primed = false;
}