From: Wei Yongjun Date: Thu, 30 Apr 2020 08:13:53 +0000 (+0000) Subject: crypto: drbg - fix error return code in drbg_alloc_state() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=e0664ebcea6ac5e16da703409fb4bd61f8cd37d9;p=linux.git 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 Fixes: db07cd26ac6a ("crypto: drbg - add FIPS 140-2 CTRNG for noise source") Cc: Signed-off-by: Wei Yongjun Reviewed-by: Stephan Mueller Signed-off-by: Herbert Xu --- diff --git a/crypto/drbg.c b/crypto/drbg.c index e57901d8545b6..37526eb8c5d57 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; }