diff options
author | Eric Biggers <ebiggers@google.com> | 2018-12-10 14:45:58 -0500 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2018-12-13 05:24:59 -0500 |
commit | 00c9fe37a7f27a306bcaa5737f0787fe139f8aba (patch) | |
tree | 879de5aacf4fef53cf165e1ad1769eff3ced4b79 | |
parent | 0ac6b8fb23c724b015d9ca70a89126e8d1563166 (diff) |
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>
-rw-r--r-- | crypto/adiantum.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/crypto/adiantum.c b/crypto/adiantum.c index e62e34f5e389..6651e713c45d 100644 --- a/crypto/adiantum.c +++ b/crypto/adiantum.c | |||
@@ -564,10 +564,8 @@ static int adiantum_create(struct crypto_template *tmpl, struct rtattr **tb) | |||
564 | hash_alg = __crypto_shash_alg(_hash_alg); | 564 | hash_alg = __crypto_shash_alg(_hash_alg); |
565 | err = crypto_init_shash_spawn(&ictx->hash_spawn, hash_alg, | 565 | err = crypto_init_shash_spawn(&ictx->hash_spawn, hash_alg, |
566 | skcipher_crypto_instance(inst)); | 566 | skcipher_crypto_instance(inst)); |
567 | if (err) { | 567 | if (err) |
568 | crypto_mod_put(_hash_alg); | 568 | goto out_put_hash; |
569 | goto out_drop_blockcipher; | ||
570 | } | ||
571 | 569 | ||
572 | /* Check the set of algorithms */ | 570 | /* Check the set of algorithms */ |
573 | if (!adiantum_supported_algorithms(streamcipher_alg, blockcipher_alg, | 571 | if (!adiantum_supported_algorithms(streamcipher_alg, blockcipher_alg, |
@@ -624,10 +622,13 @@ static int adiantum_create(struct crypto_template *tmpl, struct rtattr **tb) | |||
624 | if (err) | 622 | if (err) |
625 | goto out_drop_hash; | 623 | goto out_drop_hash; |
626 | 624 | ||
625 | crypto_mod_put(_hash_alg); | ||
627 | return 0; | 626 | return 0; |
628 | 627 | ||
629 | out_drop_hash: | 628 | out_drop_hash: |
630 | crypto_drop_shash(&ictx->hash_spawn); | 629 | crypto_drop_shash(&ictx->hash_spawn); |
630 | out_put_hash: | ||
631 | crypto_mod_put(_hash_alg); | ||
631 | out_drop_blockcipher: | 632 | out_drop_blockcipher: |
632 | crypto_drop_spawn(&ictx->blockcipher_spawn); | 633 | crypto_drop_spawn(&ictx->blockcipher_spawn); |
633 | out_drop_streamcipher: | 634 | out_drop_streamcipher: |