VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   33 Branches   55 Tags
author: Eric Biggers <ebiggers@google.com> 2021-03-21 22:07:48 -0700 committer: Herbert Xu <herbert@gondor.apana.org.au> 2021-04-02 18:28:12 +1100 commit: 30d0f6a956fc74bb2e948398daf3278c6b08c7e9 parent: 10cb823bbacd2626cca8d89a7dba175c3ae5cf07
Commit Summary:
crypto: rng - fix crypto_rng_reset() refcounting when !CRYPTO_STATS
Diffstat:
1 file changed, 3 insertions, 7 deletions
diff --git a/crypto/rng.c b/crypto/rng.c
index a888d84b524a..fea082b25fe4 100644
--- a/crypto/rng.c
+++ b/crypto/rng.c
@@ -34,22 +34,18 @@ int crypto_rng_reset(struct crypto_rng *tfm, const u8 *seed, unsigned int slen)
 	u8 *buf = NULL;
 	int err;
 
-	crypto_stats_get(alg);
 	if (!seed && slen) {
 		buf = kmalloc(slen, GFP_KERNEL);
-		if (!buf) {
-			crypto_alg_put(alg);
+		if (!buf)
 			return -ENOMEM;
-		}
 
 		err = get_random_bytes_wait(buf, slen);
-		if (err) {
-			crypto_alg_put(alg);
+		if (err)
 			goto out;
-		}
 		seed = buf;
 	}
 
+	crypto_stats_get(alg);
 	err = crypto_rng_alg(tfm)->seed(tfm, seed, slen);
 	crypto_stats_rng_seed(alg, err);
 out: