diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2015-05-22 20:34:22 +0800 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2015-05-25 18:41:25 +0800 |
commit | 1b424dc27d461540e917a6798b267c4493a845dd (patch) | |
tree | 4234d72d7c59914fa8a3b41ac7bd5264505f5f71 /crypto/pcrypt.c | |
parent | 8684eae8dddde8a05435386f6491d530e2a203e4 (diff) | |
download | linux-crypto-1b424dc27d461540e917a6798b267c4493a845dd.tar.gz linux-crypto-1b424dc27d461540e917a6798b267c4493a845dd.zip |
crypto: pcrypt - Make tfm_count an atomic_t
The variable tfm_count is accessed by multiple threads without
locking. This patch converts it to an atomic_t.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to '')
-rw-r--r-- | crypto/pcrypt.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c index 3942a9f0..ff174b61 100644 --- a/crypto/pcrypt.c +++ b/crypto/pcrypt.c @@ -20,6 +20,7 @@ #include <crypto/algapi.h> #include <crypto/internal/aead.h> +#include <linux/atomic.h> #include <linux/err.h> #include <linux/init.h> #include <linux/module.h> @@ -61,7 +62,7 @@ static struct kset *pcrypt_kset; struct pcrypt_instance_ctx { struct crypto_aead_spawn spawn; - unsigned int tfm_count; + atomic_t tfm_count; }; struct pcrypt_aead_ctx { @@ -278,9 +279,8 @@ static int pcrypt_aead_init_tfm(struct crypto_tfm *tfm) struct pcrypt_aead_ctx *ctx = crypto_tfm_ctx(tfm); struct crypto_aead *cipher; - ictx->tfm_count++; - - cpu_index = ictx->tfm_count % cpumask_weight(cpu_online_mask); + cpu_index = (unsigned int)atomic_inc_return(&ictx->tfm_count) % + cpumask_weight(cpu_online_mask); ctx->cb_cpu = cpumask_first(cpu_online_mask); for (cpu = 0; cpu < cpu_index; cpu++) |