summaryrefslogtreecommitdiff
path: root/crypto/rng.c
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2020-01-20 17:38:04 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-04-17 10:50:16 +0200
commitcbe7f79317252831105415932e1082d171a1fef3 (patch)
tree9eab4569460c841e2164d776a76ba5240fbf5116 /crypto/rng.c
parentefed299a46aa21b663fb2ab9543adb53304537fc (diff)
downloadlinux-crypto-cbe7f79317252831105415932e1082d171a1fef3.tar.gz
linux-crypto-cbe7f79317252831105415932e1082d171a1fef3.zip
crypto: rng - Fix a refcounting bug in crypto_rng_reset()
commit 9b91cc7900ce35b2e7e835726faa6295120cf839 upstream. We need to decrement this refcounter on these error paths. Fixes: 69bd3f459030 ("crypto: user - fix use_after_free of struct xxx_request") Cc: <stable@vger.kernel.org> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Acked-by: Neil Horman <nhorman@tuxdriver.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'crypto/rng.c')
-rw-r--r--crypto/rng.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/crypto/rng.c b/crypto/rng.c
index 1e21231f..1490d210 100644
--- a/crypto/rng.c
+++ b/crypto/rng.c
@@ -37,12 +37,16 @@ int crypto_rng_reset(struct crypto_rng *tfm, const u8 *seed, unsigned int slen)
crypto_stats_get(alg);
if (!seed && slen) {
buf = kmalloc(slen, GFP_KERNEL);
- if (!buf)
+ if (!buf) {
+ crypto_alg_put(alg);
return -ENOMEM;
+ }
err = get_random_bytes_wait(buf, slen);
- if (err)
+ if (err) {
+ crypto_alg_put(alg);
goto out;
+ }
seed = buf;
}