diff options
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/algapi.c | 6 | ||||
-rw-r--r-- | crypto/api.c | 20 | ||||
-rw-r--r-- | crypto/scatterwalk.c | 3 | ||||
-rw-r--r-- | crypto/shash.c | 7 |
4 files changed, 23 insertions, 13 deletions
diff --git a/crypto/algapi.c b/crypto/algapi.c index 7c41e7405c41..56c62e2858d5 100644 --- a/crypto/algapi.c +++ b/crypto/algapi.c | |||
@@ -149,6 +149,9 @@ static struct crypto_larval *__crypto_register_alg(struct crypto_alg *alg) | |||
149 | if (q == alg) | 149 | if (q == alg) |
150 | goto err; | 150 | goto err; |
151 | 151 | ||
152 | if (crypto_is_moribund(q)) | ||
153 | continue; | ||
154 | |||
152 | if (crypto_is_larval(q)) { | 155 | if (crypto_is_larval(q)) { |
153 | if (!strcmp(alg->cra_driver_name, q->cra_driver_name)) | 156 | if (!strcmp(alg->cra_driver_name, q->cra_driver_name)) |
154 | goto err; | 157 | goto err; |
@@ -197,7 +200,7 @@ void crypto_alg_tested(const char *name, int err) | |||
197 | 200 | ||
198 | down_write(&crypto_alg_sem); | 201 | down_write(&crypto_alg_sem); |
199 | list_for_each_entry(q, &crypto_alg_list, cra_list) { | 202 | list_for_each_entry(q, &crypto_alg_list, cra_list) { |
200 | if (!crypto_is_larval(q)) | 203 | if (crypto_is_moribund(q) || !crypto_is_larval(q)) |
201 | continue; | 204 | continue; |
202 | 205 | ||
203 | test = (struct crypto_larval *)q; | 206 | test = (struct crypto_larval *)q; |
@@ -210,6 +213,7 @@ void crypto_alg_tested(const char *name, int err) | |||
210 | goto unlock; | 213 | goto unlock; |
211 | 214 | ||
212 | found: | 215 | found: |
216 | q->cra_flags |= CRYPTO_ALG_DEAD; | ||
213 | alg = test->adult; | 217 | alg = test->adult; |
214 | if (err || list_empty(&alg->cra_list)) | 218 | if (err || list_empty(&alg->cra_list)) |
215 | goto complete; | 219 | goto complete; |
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 | } |
559 | EXPORT_SYMBOL_GPL(crypto_alloc_tfm); | 559 | EXPORT_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 | */ |
568 | void crypto_free_tfm(struct crypto_tfm *tfm) | 569 | void 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 | 587 | EXPORT_SYMBOL_GPL(crypto_destroy_tfm); | |
587 | EXPORT_SYMBOL_GPL(crypto_free_tfm); | ||
588 | 588 | ||
589 | int crypto_has_alg(const char *name, u32 type, u32 mask) | 589 | int crypto_has_alg(const char *name, u32 type, u32 mask) |
590 | { | 590 | { |
diff --git a/crypto/scatterwalk.c b/crypto/scatterwalk.c index 9aeeb52004a5..3de89a424401 100644 --- a/crypto/scatterwalk.c +++ b/crypto/scatterwalk.c | |||
@@ -54,7 +54,8 @@ static void scatterwalk_pagedone(struct scatter_walk *walk, int out, | |||
54 | struct page *page; | 54 | struct page *page; |
55 | 55 | ||
56 | page = sg_page(walk->sg) + ((walk->offset - 1) >> PAGE_SHIFT); | 56 | page = sg_page(walk->sg) + ((walk->offset - 1) >> PAGE_SHIFT); |
57 | flush_dcache_page(page); | 57 | if (!PageSlab(page)) |
58 | flush_dcache_page(page); | ||
58 | } | 59 | } |
59 | 60 | ||
60 | if (more) { | 61 | if (more) { |
diff --git a/crypto/shash.c b/crypto/shash.c index c9df367332ff..d5a2b619c55f 100644 --- a/crypto/shash.c +++ b/crypto/shash.c | |||
@@ -388,10 +388,15 @@ static int crypto_init_shash_ops_compat(struct crypto_tfm *tfm) | |||
388 | struct shash_desc *desc = crypto_tfm_ctx(tfm); | 388 | struct shash_desc *desc = crypto_tfm_ctx(tfm); |
389 | struct crypto_shash *shash; | 389 | struct crypto_shash *shash; |
390 | 390 | ||
391 | if (!crypto_mod_get(calg)) | ||
392 | return -EAGAIN; | ||
393 | |||
391 | shash = __crypto_shash_cast(crypto_create_tfm( | 394 | shash = __crypto_shash_cast(crypto_create_tfm( |
392 | calg, &crypto_shash_type)); | 395 | calg, &crypto_shash_type)); |
393 | if (IS_ERR(shash)) | 396 | if (IS_ERR(shash)) { |
397 | crypto_mod_put(calg); | ||
394 | return PTR_ERR(shash); | 398 | return PTR_ERR(shash); |
399 | } | ||
395 | 400 | ||
396 | desc->tfm = shash; | 401 | desc->tfm = shash; |
397 | tfm->exit = crypto_exit_shash_ops_compat; | 402 | tfm->exit = crypto_exit_shash_ops_compat; |