Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 131131
b: refs/heads/master
c: 7b2cd92
h: refs/heads/master
i:
  131129: e9d6017
  131127: e53ae96
v: v3
  • Loading branch information
Herbert Xu committed Feb 5, 2009
1 parent 333933a commit a32a4e8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4abfd73e34e7915e62b6f75bd3e9f4014f830910
refs/heads/master: 7b2cd92adc5430b0c1adeb120971852b4ea1ab08
20 changes: 10 additions & 10 deletions trunk/crypto/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -557,34 +557,34 @@ struct crypto_tfm *crypto_alloc_tfm(const char *alg_name,
return ERR_PTR(err);
}
EXPORT_SYMBOL_GPL(crypto_alloc_tfm);

/*
* crypto_free_tfm - Free crypto transform
* crypto_destroy_tfm - Free crypto transform
* @mem: Start of tfm slab
* @tfm: Transform to free
*
* crypto_free_tfm() frees up the transform and any associated resources,
* This function frees up the transform and any associated resources,
* then drops the refcount on the associated algorithm.
*/
void crypto_free_tfm(struct crypto_tfm *tfm)
void crypto_destroy_tfm(void *mem, struct crypto_tfm *tfm)
{
struct crypto_alg *alg;
int size;

if (unlikely(!tfm))
if (unlikely(!mem))
return;

alg = tfm->__crt_alg;
size = sizeof(*tfm) + alg->cra_ctxsize;
size = ksize(mem);

if (!tfm->exit && alg->cra_exit)
alg->cra_exit(tfm);
crypto_exit_ops(tfm);
crypto_mod_put(alg);
memset(tfm, 0, size);
kfree(tfm);
memset(mem, 0, size);
kfree(mem);
}

EXPORT_SYMBOL_GPL(crypto_free_tfm);
EXPORT_SYMBOL_GPL(crypto_destroy_tfm);

int crypto_has_alg(const char *name, u32 type, u32 mask)
{
Expand Down
7 changes: 6 additions & 1 deletion trunk/include/linux/crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,12 @@ struct crypto_tfm *crypto_alloc_tfm(const char *alg_name,
const struct crypto_type *frontend,
u32 type, u32 mask);
struct crypto_tfm *crypto_alloc_base(const char *alg_name, u32 type, u32 mask);
void crypto_free_tfm(struct crypto_tfm *tfm);
void crypto_destroy_tfm(void *mem, struct crypto_tfm *tfm);

static inline void crypto_free_tfm(struct crypto_tfm *tfm)
{
return crypto_destroy_tfm(tfm, tfm);
}

int alg_test(const char *driver, const char *alg, u32 type, u32 mask);

Expand Down

0 comments on commit a32a4e8

Please sign in to comment.