Commit 00c9fe37 authored by Eric Biggers's avatar Eric Biggers Committed by Herbert Xu

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: 059c2a4d ("crypto: adiantum - add Adiantum support")
Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 0ac6b8fb
...@@ -564,10 +564,8 @@ static int adiantum_create(struct crypto_template *tmpl, struct rtattr **tb) ...@@ -564,10 +564,8 @@ static int adiantum_create(struct crypto_template *tmpl, struct rtattr **tb)
hash_alg = __crypto_shash_alg(_hash_alg); hash_alg = __crypto_shash_alg(_hash_alg);
err = crypto_init_shash_spawn(&ictx->hash_spawn, hash_alg, err = crypto_init_shash_spawn(&ictx->hash_spawn, hash_alg,
skcipher_crypto_instance(inst)); skcipher_crypto_instance(inst));
if (err) { if (err)
crypto_mod_put(_hash_alg); goto out_put_hash;
goto out_drop_blockcipher;
}
/* Check the set of algorithms */ /* Check the set of algorithms */
if (!adiantum_supported_algorithms(streamcipher_alg, blockcipher_alg, if (!adiantum_supported_algorithms(streamcipher_alg, blockcipher_alg,
...@@ -624,10 +622,13 @@ static int adiantum_create(struct crypto_template *tmpl, struct rtattr **tb) ...@@ -624,10 +622,13 @@ static int adiantum_create(struct crypto_template *tmpl, struct rtattr **tb)
if (err) if (err)
goto out_drop_hash; goto out_drop_hash;
crypto_mod_put(_hash_alg);
return 0; return 0;
out_drop_hash: out_drop_hash:
crypto_drop_shash(&ictx->hash_spawn); crypto_drop_shash(&ictx->hash_spawn);
out_put_hash:
crypto_mod_put(_hash_alg);
out_drop_blockcipher: out_drop_blockcipher:
crypto_drop_spawn(&ictx->blockcipher_spawn); crypto_drop_spawn(&ictx->blockcipher_spawn);
out_drop_streamcipher: out_drop_streamcipher:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment