diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2020-01-20 17:38:04 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-04-17 10:50:16 +0200 |
commit | 248414f50596b2d7cc2721c826c48fde2b6b2f5f (patch) | |
tree | f0985dd2b6e43bb676712a61f8fd43c29d531170 /crypto | |
parent | 6b936b1872baeb72dd705f9c91803b9c805d1125 (diff) | |
download | linux-stable-248414f50596b2d7cc2721c826c48fde2b6b2f5f.tar.gz linux-stable-248414f50596b2d7cc2721c826c48fde2b6b2f5f.tar.bz2 linux-stable-248414f50596b2d7cc2721c826c48fde2b6b2f5f.zip |
crypto: rng - Fix a refcounting bug in crypto_rng_reset()
commit eed74b3eba9eda36d155c11a12b2b4b50c67c1d8 upstream.
We need to decrement this refcounter on these error paths.
Fixes: f7d76e05d058 ("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')
-rw-r--r-- | crypto/rng.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/crypto/rng.c b/crypto/rng.c index 1e21231f71c9..1490d210f1a1 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; } |