diff mbox series

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

Message ID 20200430081353.112449-1-weiyongjun1@huawei.com
State New
Headers show
Series [-next] crypto: drbg - fix error return code in drbg_alloc_state() | expand

Commit Message

Wei Yongjun April 30, 2020, 8:13 a.m. UTC
Fix to return negative error code -ENOMEM from the kzalloc error handling
case instead of 0, as done elsewhere in this function.

Fixes: db07cd26ac6a ("crypto: drbg - add FIPS 140-2 CTRNG for noise source")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 crypto/drbg.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/crypto/drbg.c b/crypto/drbg.c
index e57901d8545b..37526eb8c5d5 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;
 	}