diff options
author | Wei Yongjun <weiyongjun1@huawei.com> | 2020-04-30 08:13:53 +0000 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2020-05-08 15:30:41 +1000 |
commit | 4e74a113fa130f456485cc3f2460ca743aadf8aa (patch) | |
tree | 7f04e1a58114b209eb1c2ec1bdb7dd84fc176e83 /crypto/drbg.c | |
parent | d87bb7584bf1fed90dc9fbb048b80a1df1bac508 (diff) | |
download | linux-crypto-4e74a113fa130f456485cc3f2460ca743aadf8aa.tar.gz linux-crypto-4e74a113fa130f456485cc3f2460ca743aadf8aa.zip |
crypto: drbg - fix error return code in drbg_alloc_state()
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: 384577283cad ("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>
Diffstat (limited to 'crypto/drbg.c')
-rw-r--r-- | crypto/drbg.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/crypto/drbg.c b/crypto/drbg.c index e57901d8..37526eb8 100644 --- a/crypto/drbg.c +++ b/crypto/drbg.c @@ -1306,8 +1306,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; } |