diff options
author | Ingo Molnar <mingo@elte.hu> | 2009-03-26 13:29:40 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-03-26 13:29:40 -0400 |
commit | 5a54bd1307471c1cd0521402fe65e2057edcab2f (patch) | |
tree | 25fb6a543db4ccc11b6d5662ed2e7facfce39ae7 /crypto/api.c | |
parent | f9f35677d81adb0feedcd6e0e661784805c8facd (diff) | |
parent | 8e0ee43bc2c3e19db56a4adaa9a9b04ce885cd84 (diff) |
Merge commit 'v2.6.29' into core/header-fixes
Diffstat (limited to 'crypto/api.c')
-rw-r--r-- | crypto/api.c | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/crypto/api.c b/crypto/api.c index 9975a7bd246c..38a2bc02a98c 100644 --- a/crypto/api.c +++ b/crypto/api.c | |||
@@ -215,8 +215,19 @@ struct crypto_alg *crypto_larval_lookup(const char *name, u32 type, u32 mask) | |||
215 | mask &= ~(CRYPTO_ALG_LARVAL | CRYPTO_ALG_DEAD); | 215 | mask &= ~(CRYPTO_ALG_LARVAL | CRYPTO_ALG_DEAD); |
216 | type &= mask; | 216 | type &= mask; |
217 | 217 | ||
218 | alg = try_then_request_module(crypto_alg_lookup(name, type, mask), | 218 | alg = crypto_alg_lookup(name, type, mask); |
219 | name); | 219 | if (!alg) { |
220 | char tmp[CRYPTO_MAX_ALG_NAME]; | ||
221 | |||
222 | request_module(name); | ||
223 | |||
224 | if (!((type ^ CRYPTO_ALG_NEED_FALLBACK) & mask) && | ||
225 | snprintf(tmp, sizeof(tmp), "%s-all", name) < sizeof(tmp)) | ||
226 | request_module(tmp); | ||
227 | |||
228 | alg = crypto_alg_lookup(name, type, mask); | ||
229 | } | ||
230 | |||
220 | if (alg) | 231 | if (alg) |
221 | return crypto_is_larval(alg) ? crypto_larval_wait(alg) : alg; | 232 | return crypto_is_larval(alg) ? crypto_larval_wait(alg) : alg; |
222 | 233 | ||
@@ -557,34 +568,34 @@ err: | |||
557 | return ERR_PTR(err); | 568 | return ERR_PTR(err); |
558 | } | 569 | } |
559 | EXPORT_SYMBOL_GPL(crypto_alloc_tfm); | 570 | EXPORT_SYMBOL_GPL(crypto_alloc_tfm); |
560 | 571 | ||
561 | /* | 572 | /* |
562 | * crypto_free_tfm - Free crypto transform | 573 | * crypto_destroy_tfm - Free crypto transform |
574 | * @mem: Start of tfm slab | ||
563 | * @tfm: Transform to free | 575 | * @tfm: Transform to free |
564 | * | 576 | * |
565 | * crypto_free_tfm() frees up the transform and any associated resources, | 577 | * This function frees up the transform and any associated resources, |
566 | * then drops the refcount on the associated algorithm. | 578 | * then drops the refcount on the associated algorithm. |
567 | */ | 579 | */ |
568 | void crypto_free_tfm(struct crypto_tfm *tfm) | 580 | void crypto_destroy_tfm(void *mem, struct crypto_tfm *tfm) |
569 | { | 581 | { |
570 | struct crypto_alg *alg; | 582 | struct crypto_alg *alg; |
571 | int size; | 583 | int size; |
572 | 584 | ||
573 | if (unlikely(!tfm)) | 585 | if (unlikely(!mem)) |
574 | return; | 586 | return; |
575 | 587 | ||
576 | alg = tfm->__crt_alg; | 588 | alg = tfm->__crt_alg; |
577 | size = sizeof(*tfm) + alg->cra_ctxsize; | 589 | size = ksize(mem); |
578 | 590 | ||
579 | if (!tfm->exit && alg->cra_exit) | 591 | if (!tfm->exit && alg->cra_exit) |
580 | alg->cra_exit(tfm); | 592 | alg->cra_exit(tfm); |
581 | crypto_exit_ops(tfm); | 593 | crypto_exit_ops(tfm); |
582 | crypto_mod_put(alg); | 594 | crypto_mod_put(alg); |
583 | memset(tfm, 0, size); | 595 | memset(mem, 0, size); |
584 | kfree(tfm); | 596 | kfree(mem); |
585 | } | 597 | } |
586 | 598 | EXPORT_SYMBOL_GPL(crypto_destroy_tfm); | |
587 | EXPORT_SYMBOL_GPL(crypto_free_tfm); | ||
588 | 599 | ||
589 | int crypto_has_alg(const char *name, u32 type, u32 mask) | 600 | int crypto_has_alg(const char *name, u32 type, u32 mask) |
590 | { | 601 | { |