Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Dmitry Safonov and committed by
Herbert Xu
9979c6e5 fa3b3565

+6 -1
+6 -1
crypto/cipher.c
··· 101 101 if (alg->cra_init) 102 102 return ERR_PTR(-ENOSYS); 103 103 104 + if (unlikely(!crypto_mod_get(alg))) 105 + return ERR_PTR(-ESTALE); 106 + 104 107 ntfm = __crypto_alloc_tfmgfp(alg, CRYPTO_ALG_TYPE_CIPHER, 105 108 CRYPTO_ALG_TYPE_MASK, GFP_ATOMIC); 106 - if (IS_ERR(ntfm)) 109 + if (IS_ERR(ntfm)) { 110 + crypto_mod_put(alg); 107 111 return ERR_CAST(ntfm); 112 + } 108 113 109 114 ntfm->crt_flags = tfm->crt_flags; 110 115