diff options
Diffstat (limited to 'crypto/api.c')
-rw-r--r-- | crypto/api.c | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/crypto/api.c b/crypto/api.c index 38a2bc02a98c..d5944f92b416 100644 --- a/crypto/api.c +++ b/crypto/api.c | |||
@@ -217,13 +217,11 @@ struct crypto_alg *crypto_larval_lookup(const char *name, u32 type, u32 mask) | |||
217 | 217 | ||
218 | alg = crypto_alg_lookup(name, type, mask); | 218 | alg = crypto_alg_lookup(name, type, mask); |
219 | if (!alg) { | 219 | if (!alg) { |
220 | char tmp[CRYPTO_MAX_ALG_NAME]; | 220 | request_module("%s", name); |
221 | 221 | ||
222 | request_module(name); | 222 | if (!((type ^ CRYPTO_ALG_NEED_FALLBACK) & mask & |
223 | 223 | CRYPTO_ALG_NEED_FALLBACK)) | |
224 | if (!((type ^ CRYPTO_ALG_NEED_FALLBACK) & mask) && | 224 | request_module("%s-all", name); |
225 | snprintf(tmp, sizeof(tmp), "%s-all", name) < sizeof(tmp)) | ||
226 | request_module(tmp); | ||
227 | 225 | ||
228 | alg = crypto_alg_lookup(name, type, mask); | 226 | alg = crypto_alg_lookup(name, type, mask); |
229 | } | 227 | } |
@@ -255,7 +253,7 @@ struct crypto_alg *crypto_alg_mod_lookup(const char *name, u32 type, u32 mask) | |||
255 | struct crypto_alg *larval; | 253 | struct crypto_alg *larval; |
256 | int ok; | 254 | int ok; |
257 | 255 | ||
258 | if (!(mask & CRYPTO_ALG_TESTED)) { | 256 | if (!((type | mask) & CRYPTO_ALG_TESTED)) { |
259 | type |= CRYPTO_ALG_TESTED; | 257 | type |= CRYPTO_ALG_TESTED; |
260 | mask |= CRYPTO_ALG_TESTED; | 258 | mask |= CRYPTO_ALG_TESTED; |
261 | } | 259 | } |
@@ -464,8 +462,8 @@ err: | |||
464 | } | 462 | } |
465 | EXPORT_SYMBOL_GPL(crypto_alloc_base); | 463 | EXPORT_SYMBOL_GPL(crypto_alloc_base); |
466 | 464 | ||
467 | struct crypto_tfm *crypto_create_tfm(struct crypto_alg *alg, | 465 | void *crypto_create_tfm(struct crypto_alg *alg, |
468 | const struct crypto_type *frontend) | 466 | const struct crypto_type *frontend) |
469 | { | 467 | { |
470 | char *mem; | 468 | char *mem; |
471 | struct crypto_tfm *tfm = NULL; | 469 | struct crypto_tfm *tfm = NULL; |
@@ -499,9 +497,9 @@ out_free_tfm: | |||
499 | crypto_shoot_alg(alg); | 497 | crypto_shoot_alg(alg); |
500 | kfree(mem); | 498 | kfree(mem); |
501 | out_err: | 499 | out_err: |
502 | tfm = ERR_PTR(err); | 500 | mem = ERR_PTR(err); |
503 | out: | 501 | out: |
504 | return tfm; | 502 | return mem; |
505 | } | 503 | } |
506 | EXPORT_SYMBOL_GPL(crypto_create_tfm); | 504 | EXPORT_SYMBOL_GPL(crypto_create_tfm); |
507 | 505 | ||
@@ -525,12 +523,11 @@ EXPORT_SYMBOL_GPL(crypto_create_tfm); | |||
525 | * | 523 | * |
526 | * In case of error the return value is an error pointer. | 524 | * In case of error the return value is an error pointer. |
527 | */ | 525 | */ |
528 | struct crypto_tfm *crypto_alloc_tfm(const char *alg_name, | 526 | void *crypto_alloc_tfm(const char *alg_name, |
529 | const struct crypto_type *frontend, | 527 | const struct crypto_type *frontend, u32 type, u32 mask) |
530 | u32 type, u32 mask) | ||
531 | { | 528 | { |
532 | struct crypto_alg *(*lookup)(const char *name, u32 type, u32 mask); | 529 | struct crypto_alg *(*lookup)(const char *name, u32 type, u32 mask); |
533 | struct crypto_tfm *tfm; | 530 | void *tfm; |
534 | int err; | 531 | int err; |
535 | 532 | ||
536 | type &= frontend->maskclear; | 533 | type &= frontend->maskclear; |
@@ -580,20 +577,17 @@ EXPORT_SYMBOL_GPL(crypto_alloc_tfm); | |||
580 | void crypto_destroy_tfm(void *mem, struct crypto_tfm *tfm) | 577 | void crypto_destroy_tfm(void *mem, struct crypto_tfm *tfm) |
581 | { | 578 | { |
582 | struct crypto_alg *alg; | 579 | struct crypto_alg *alg; |
583 | int size; | ||
584 | 580 | ||
585 | if (unlikely(!mem)) | 581 | if (unlikely(!mem)) |
586 | return; | 582 | return; |
587 | 583 | ||
588 | alg = tfm->__crt_alg; | 584 | alg = tfm->__crt_alg; |
589 | size = ksize(mem); | ||
590 | 585 | ||
591 | if (!tfm->exit && alg->cra_exit) | 586 | if (!tfm->exit && alg->cra_exit) |
592 | alg->cra_exit(tfm); | 587 | alg->cra_exit(tfm); |
593 | crypto_exit_ops(tfm); | 588 | crypto_exit_ops(tfm); |
594 | crypto_mod_put(alg); | 589 | crypto_mod_put(alg); |
595 | memset(mem, 0, size); | 590 | kzfree(mem); |
596 | kfree(mem); | ||
597 | } | 591 | } |
598 | EXPORT_SYMBOL_GPL(crypto_destroy_tfm); | 592 | EXPORT_SYMBOL_GPL(crypto_destroy_tfm); |
599 | 593 | ||