diff options
author | Eric Biggers <ebiggers@google.com> | 2017-12-29 10:00:46 -0600 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2018-01-05 18:43:09 +1100 |
commit | 2431f0da543e8c93333ed3b3c8ab9a1158404959 (patch) | |
tree | 61ec83a2a3b013ba8078d74be682dffa584a8109 /crypto/internal.h | |
parent | aa6bade9aa65fa4e09010f6c744f4727fce612de (diff) | |
download | linux-crypto-2431f0da543e8c93333ed3b3c8ab9a1158404959.tar.gz linux-crypto-2431f0da543e8c93333ed3b3c8ab9a1158404959.zip |
crypto: algapi - convert cra_refcnt to refcount_t
Reference counters should use refcount_t rather than atomic_t, since the
refcount_t implementation can prevent overflows, reducing the
exploitability of reference leak bugs. crypto_alg.cra_refcount is a
reference counter with the usual semantics, so switch it over to
refcount_t.
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/internal.h')
-rw-r--r-- | crypto/internal.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/crypto/internal.h b/crypto/internal.h index ae65e5fc..1388af6d 100644 --- a/crypto/internal.h +++ b/crypto/internal.h @@ -105,13 +105,13 @@ int crypto_type_has_alg(const char *name, const struct crypto_type *frontend, static inline struct crypto_alg *crypto_alg_get(struct crypto_alg *alg) { - atomic_inc(&alg->cra_refcnt); + refcount_inc(&alg->cra_refcnt); return alg; } static inline void crypto_alg_put(struct crypto_alg *alg) { - if (atomic_dec_and_test(&alg->cra_refcnt) && alg->cra_destroy) + if (refcount_dec_and_test(&alg->cra_refcnt) && alg->cra_destroy) alg->cra_destroy(alg); } |