aboutsummaryrefslogtreecommitdiff
path: root/crypto/internal.h
diff options
context:
space:
mode:
authorGravatar Herbert Xu <herbert@gondor.apana.org.au> 2023-04-13 14:24:15 +0800
committerGravatar Herbert Xu <herbert@gondor.apana.org.au> 2023-04-20 18:20:04 +0800
commitae131f4970f0778f35ed06aeb15bde2fbc1d9619 (patch)
tree32129d0609ff52d6742628db8f284e33274c95a7 /crypto/internal.h
parentcrypto: x86/sha - Use local .L symbols for code (diff)
downloadlinux-ae131f4970f0778f35ed06aeb15bde2fbc1d9619.tar.gz
linux-ae131f4970f0778f35ed06aeb15bde2fbc1d9619.tar.bz2
linux-ae131f4970f0778f35ed06aeb15bde2fbc1d9619.zip
crypto: api - Add crypto_tfm_get
Add a crypto_tfm_get interface to allow tfm objects to be shared. They can still be freed in the usual way. This should only be done with tfm objects with no keys. You must also not modify the tfm flags in any way once it becomes shared. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Reviewed-by: Simon Horman <simon.horman@corigine.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/internal.h')
-rw-r--r--crypto/internal.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/crypto/internal.h b/crypto/internal.h
index f84dfe6491e5..5eee009ee494 100644
--- a/crypto/internal.h
+++ b/crypto/internal.h
@@ -10,6 +10,7 @@
#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>
@@ -186,5 +187,10 @@ static inline int crypto_is_test_larval(struct crypto_larval *larval)
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 */