mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
crypto: cipher - On clone do crypto_mod_get()
The refcounter of underlying algorithm should be incremented, otherwise it'll be destroyed with the cloned cipher, wrecking the original cipher. Signed-off-by: Dmitry Safonov <dima@arista.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
fa3b3565f3
commit
9979c6e55d
1 changed files with 6 additions and 1 deletions
|
@ -101,10 +101,15 @@ struct crypto_cipher *crypto_clone_cipher(struct crypto_cipher *cipher)
|
||||||
if (alg->cra_init)
|
if (alg->cra_init)
|
||||||
return ERR_PTR(-ENOSYS);
|
return ERR_PTR(-ENOSYS);
|
||||||
|
|
||||||
|
if (unlikely(!crypto_mod_get(alg)))
|
||||||
|
return ERR_PTR(-ESTALE);
|
||||||
|
|
||||||
ntfm = __crypto_alloc_tfmgfp(alg, CRYPTO_ALG_TYPE_CIPHER,
|
ntfm = __crypto_alloc_tfmgfp(alg, CRYPTO_ALG_TYPE_CIPHER,
|
||||||
CRYPTO_ALG_TYPE_MASK, GFP_ATOMIC);
|
CRYPTO_ALG_TYPE_MASK, GFP_ATOMIC);
|
||||||
if (IS_ERR(ntfm))
|
if (IS_ERR(ntfm)) {
|
||||||
|
crypto_mod_put(alg);
|
||||||
return ERR_CAST(ntfm);
|
return ERR_CAST(ntfm);
|
||||||
|
}
|
||||||
|
|
||||||
ntfm->crt_flags = tfm->crt_flags;
|
ntfm->crt_flags = tfm->crt_flags;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue