[CRYPTO] api: Add crypto_alg reference counting
Up until now we've relied on module reference counting to ensure that the crypto_alg structures don't disappear from under us. This was good enough as long as each crypto_alg came from exactly one module. However, with parameterised crypto algorithms a crypto_alg object may need two or more modules to operate. This means that we need to count the references to the crypto_alg object directly. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#ifndef _LINUX_CRYPTO_H
|
||||
#define _LINUX_CRYPTO_H
|
||||
|
||||
#include <asm/atomic.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/types.h>
|
||||
@@ -148,6 +149,7 @@ struct crypto_alg {
|
||||
unsigned int cra_alignmask;
|
||||
|
||||
int cra_priority;
|
||||
atomic_t cra_refcnt;
|
||||
|
||||
char cra_name[CRYPTO_MAX_ALG_NAME];
|
||||
char cra_driver_name[CRYPTO_MAX_ALG_NAME];
|
||||
@@ -160,6 +162,7 @@ struct crypto_alg {
|
||||
|
||||
int (*cra_init)(struct crypto_tfm *tfm);
|
||||
void (*cra_exit)(struct crypto_tfm *tfm);
|
||||
void (*cra_destroy)(struct crypto_alg *alg);
|
||||
|
||||
struct module *cra_module;
|
||||
};
|
||||
|
Reference in New Issue
Block a user