summaryrefslogtreecommitdiff
authorEric Biggers <ebiggers@google.com>2018-12-10 19:45:58 (GMT)
committer Eric Biggers <ebiggers@google.com>2019-01-18 20:43:35 (GMT)
commitb05264180a4d16c5b95cba9e66db33b06c68f032 (patch)
tree5d98969af1289ddaf893d04acaa108b78419a73a
parentdcdbb165a2383d98507bce78bcf26b969d41af9d (diff)
downloadcommon-b05264180a4d16c5b95cba9e66db33b06c68f032.zip
common-b05264180a4d16c5b95cba9e66db33b06c68f032.tar.gz
common-b05264180a4d16c5b95cba9e66db33b06c68f032.tar.bz2
UPSTREAM: crypto: adiantum - fix leaking reference to hash algorithm
crypto_alg_mod_lookup() takes a reference to the hash algorithm but crypto_init_shash_spawn() doesn't take ownership of it, hence the reference needs to be dropped in adiantum_create(). Fixes: 059c2a4d8e16 ("crypto: adiantum - add Adiantum support") Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> (cherry picked from commit 00c9fe37a7f27a306bcaa5737f0787fe139f8aba) Test: Adiantum self-tests Change-Id: Ic609144bc3c72cc2c4ccbbaf450168193f3df7db
Diffstat
-rw-r--r--crypto/adiantum.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/crypto/adiantum.c b/crypto/adiantum.c
index e62e34f..6651e71 100644
--- a/crypto/adiantum.c
+++ b/crypto/adiantum.c
@@ -564,10 +564,8 @@ static int adiantum_create(struct crypto_template *tmpl, struct rtattr **tb)
hash_alg = __crypto_shash_alg(_hash_alg);
err = crypto_init_shash_spawn(&ictx->hash_spawn, hash_alg,
skcipher_crypto_instance(inst));
- if (err) {
- crypto_mod_put(_hash_alg);
- goto out_drop_blockcipher;
- }
+ if (err)
+ goto out_put_hash;
/* Check the set of algorithms */
if (!adiantum_supported_algorithms(streamcipher_alg, blockcipher_alg,
@@ -624,10 +622,13 @@ static int adiantum_create(struct crypto_template *tmpl, struct rtattr **tb)
if (err)
goto out_drop_hash;
+ crypto_mod_put(_hash_alg);
return 0;
out_drop_hash:
crypto_drop_shash(&ictx->hash_spawn);
+out_put_hash:
+ crypto_mod_put(_hash_alg);
out_drop_blockcipher:
crypto_drop_spawn(&ictx->blockcipher_spawn);
out_drop_streamcipher: