提交 a5a22e57 编写于 作者: H Herbert Xu

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: NHerbert Xu <herbert@gondor.apana.org.au>
上级 30e4c010
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <crypto/algapi.h> #include <crypto/algapi.h>
#include <crypto/internal/aead.h> #include <crypto/internal/aead.h>
#include <linux/atomic.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/module.h> #include <linux/module.h>
...@@ -61,7 +62,7 @@ static struct kset *pcrypt_kset; ...@@ -61,7 +62,7 @@ static struct kset *pcrypt_kset;
struct pcrypt_instance_ctx { struct pcrypt_instance_ctx {
struct crypto_aead_spawn spawn; struct crypto_aead_spawn spawn;
unsigned int tfm_count; atomic_t tfm_count;
}; };
struct pcrypt_aead_ctx { struct pcrypt_aead_ctx {
...@@ -278,9 +279,8 @@ static int pcrypt_aead_init_tfm(struct crypto_tfm *tfm) ...@@ -278,9 +279,8 @@ static int pcrypt_aead_init_tfm(struct crypto_tfm *tfm)
struct pcrypt_aead_ctx *ctx = crypto_tfm_ctx(tfm); struct pcrypt_aead_ctx *ctx = crypto_tfm_ctx(tfm);
struct crypto_aead *cipher; struct crypto_aead *cipher;
ictx->tfm_count++; cpu_index = (unsigned int)atomic_inc_return(&ictx->tfm_count) %
cpumask_weight(cpu_online_mask);
cpu_index = ictx->tfm_count % cpumask_weight(cpu_online_mask);
ctx->cb_cpu = cpumask_first(cpu_online_mask); ctx->cb_cpu = cpumask_first(cpu_online_mask);
for (cpu = 0; cpu < cpu_index; cpu++) for (cpu = 0; cpu < cpu_index; cpu++)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册