This reverts commit
ae131f4970f0 ("crypto: api - Add crypto_tfm_get").
The refcount in struct crypto_tfm was added solely to support
crypto_clone_tfm(). Before then it was a simple non-refcounted object.
Since crypto_clone_tfm() has been removed, remove the refcount as well.
Note that this eliminates an expensive atomic operation from every tfm
freeing operation. So this revert doesn't just remove unused code, but
it also fixes a performance regression.
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
Link: https://patch.msgid.link/20260522053028.91165-5-ebiggers@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
goto out_err;
tfm->__crt_alg = alg;
- refcount_set(&tfm->refcnt, 1);
if (!tfm->exit && alg->cra_init && (err = alg->cra_init(tfm)))
goto cra_init_failed;
tfm = (struct crypto_tfm *)(mem + tfmsize);
tfm->__crt_alg = alg;
tfm->node = node;
- refcount_set(&tfm->refcnt, 1);
return mem;
}
if (IS_ERR_OR_NULL(mem))
return;
- if (!refcount_dec_and_test(&tfm->refcnt))
- return;
alg = tfm->__crt_alg;
if (!tfm->exit && alg->cra_exit)
#include <crypto/algapi.h>
#include <linux/completion.h>
-#include <linux/err.h>
#include <linux/jump_label.h>
#include <linux/list.h>
#include <linux/module.h>
return larval->alg.cra_driver_name[0];
}
-static inline struct crypto_tfm *crypto_tfm_get(struct crypto_tfm *tfm)
-{
- return refcount_inc_not_zero(&tfm->refcnt) ? tfm : ERR_PTR(-EOVERFLOW);
-}
-
#endif /* _CRYPTO_INTERNAL_H */
*/
struct crypto_tfm {
- refcount_t refcnt;
u32 crt_flags;