Commit e0664ebc authored by Wei Yongjun's avatar Wei Yongjun Committed by Herbert Xu

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: default avatarXiumei Mu <xmu@redhat.com>
Fixes: db07cd26 ("crypto: drbg - add FIPS 140-2 CTRNG for noise source")
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarWei Yongjun <weiyongjun1@huawei.com>
Reviewed-by: default avatarStephan Mueller <smueller@chronox.de>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent c5492269
...@@ -1306,8 +1306,10 @@ static inline int drbg_alloc_state(struct drbg_state *drbg) ...@@ -1306,8 +1306,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;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment