aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2009-02-05 00:48:24 -0500
committerHerbert Xu <herbert@gondor.apana.org.au>2009-02-05 00:48:53 -0500
commit7b2cd92adc5430b0c1adeb120971852b4ea1ab08 (patch)
tree217ce22454d6e1d14b4a6e77db6cf60c8e725c12 /crypto
parent4abfd73e34e7915e62b6f75bd3e9f4014f830910 (diff)
crypto: api - Fix zeroing on free
Geert Uytterhoeven pointed out that we're not zeroing all the memory when freeing a transform. This patch fixes it by calling ksize to ensure that we zero everything in sight. Reported-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/api.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/crypto/api.c b/crypto/api.c
index 9975a7bd246c..efe77df6863f 100644
--- a/crypto/api.c
+++ b/crypto/api.c
@@ -557,34 +557,34 @@ err:
557 return ERR_PTR(err); 557 return ERR_PTR(err);
558} 558}
559EXPORT_SYMBOL_GPL(crypto_alloc_tfm); 559EXPORT_SYMBOL_GPL(crypto_alloc_tfm);
560 560
561/* 561/*
562 * crypto_free_tfm - Free crypto transform 562 * crypto_destroy_tfm - Free crypto transform
563 * @mem: Start of tfm slab
563 * @tfm: Transform to free 564 * @tfm: Transform to free
564 * 565 *
565 * crypto_free_tfm() frees up the transform and any associated resources, 566 * This function frees up the transform and any associated resources,
566 * then drops the refcount on the associated algorithm. 567 * then drops the refcount on the associated algorithm.
567 */ 568 */
568void crypto_free_tfm(struct crypto_tfm *tfm) 569void crypto_destroy_tfm(void *mem, struct crypto_tfm *tfm)
569{ 570{
570 struct crypto_alg *alg; 571 struct crypto_alg *alg;
571 int size; 572 int size;
572 573
573 if (unlikely(!tfm)) 574 if (unlikely(!mem))
574 return; 575 return;
575 576
576 alg = tfm->__crt_alg; 577 alg = tfm->__crt_alg;
577 size = sizeof(*tfm) + alg->cra_ctxsize; 578 size = ksize(mem);
578 579
579 if (!tfm->exit && alg->cra_exit) 580 if (!tfm->exit && alg->cra_exit)
580 alg->cra_exit(tfm); 581 alg->cra_exit(tfm);
581 crypto_exit_ops(tfm); 582 crypto_exit_ops(tfm);
582 crypto_mod_put(alg); 583 crypto_mod_put(alg);
583 memset(tfm, 0, size); 584 memset(mem, 0, size);
584 kfree(tfm); 585 kfree(mem);
585} 586}
586 587EXPORT_SYMBOL_GPL(crypto_destroy_tfm);
587EXPORT_SYMBOL_GPL(crypto_free_tfm);
588 588
589int crypto_has_alg(const char *name, u32 type, u32 mask) 589int crypto_has_alg(const char *name, u32 type, u32 mask)
590{ 590{