diff options
| -rw-r--r-- | crypto/algboss.c | 15 | ||||
| -rw-r--r-- | crypto/api.c | 6 | ||||
| -rw-r--r-- | crypto/internal.h | 6 |
3 files changed, 14 insertions, 13 deletions
diff --git a/crypto/algboss.c b/crypto/algboss.c index 769219b29309..76fc0b23fc6c 100644 --- a/crypto/algboss.c +++ b/crypto/algboss.c | |||
| @@ -45,10 +45,9 @@ struct cryptomgr_param { | |||
| 45 | } nu32; | 45 | } nu32; |
| 46 | } attrs[CRYPTO_MAX_ATTRS]; | 46 | } attrs[CRYPTO_MAX_ATTRS]; |
| 47 | 47 | ||
| 48 | char larval[CRYPTO_MAX_ALG_NAME]; | ||
| 49 | char template[CRYPTO_MAX_ALG_NAME]; | 48 | char template[CRYPTO_MAX_ALG_NAME]; |
| 50 | 49 | ||
| 51 | struct completion *completion; | 50 | struct crypto_larval *larval; |
| 52 | 51 | ||
| 53 | u32 otype; | 52 | u32 otype; |
| 54 | u32 omask; | 53 | u32 omask; |
| @@ -87,7 +86,8 @@ static int cryptomgr_probe(void *data) | |||
| 87 | crypto_tmpl_put(tmpl); | 86 | crypto_tmpl_put(tmpl); |
| 88 | 87 | ||
| 89 | out: | 88 | out: |
| 90 | complete_all(param->completion); | 89 | complete_all(¶m->larval->completion); |
| 90 | crypto_alg_put(¶m->larval->alg); | ||
| 91 | kfree(param); | 91 | kfree(param); |
| 92 | module_put_and_exit(0); | 92 | module_put_and_exit(0); |
| 93 | } | 93 | } |
| @@ -187,18 +187,19 @@ static int cryptomgr_schedule_probe(struct crypto_larval *larval) | |||
| 187 | param->otype = larval->alg.cra_flags; | 187 | param->otype = larval->alg.cra_flags; |
| 188 | param->omask = larval->mask; | 188 | param->omask = larval->mask; |
| 189 | 189 | ||
| 190 | memcpy(param->larval, larval->alg.cra_name, CRYPTO_MAX_ALG_NAME); | 190 | crypto_alg_get(&larval->alg); |
| 191 | 191 | param->larval = larval; | |
| 192 | param->completion = &larval->completion; | ||
| 193 | 192 | ||
| 194 | thread = kthread_run(cryptomgr_probe, param, "cryptomgr_probe"); | 193 | thread = kthread_run(cryptomgr_probe, param, "cryptomgr_probe"); |
| 195 | if (IS_ERR(thread)) | 194 | if (IS_ERR(thread)) |
| 196 | goto err_free_param; | 195 | goto err_put_larval; |
| 197 | 196 | ||
| 198 | wait_for_completion_interruptible(&larval->completion); | 197 | wait_for_completion_interruptible(&larval->completion); |
| 199 | 198 | ||
| 200 | return NOTIFY_STOP; | 199 | return NOTIFY_STOP; |
| 201 | 200 | ||
| 201 | err_put_larval: | ||
| 202 | crypto_alg_put(&larval->alg); | ||
| 202 | err_free_param: | 203 | err_free_param: |
| 203 | kfree(param); | 204 | kfree(param); |
| 204 | err_put_module: | 205 | err_put_module: |
diff --git a/crypto/api.c b/crypto/api.c index 033a7147e5eb..3b6180336d3d 100644 --- a/crypto/api.c +++ b/crypto/api.c | |||
| @@ -34,12 +34,6 @@ EXPORT_SYMBOL_GPL(crypto_alg_sem); | |||
| 34 | BLOCKING_NOTIFIER_HEAD(crypto_chain); | 34 | BLOCKING_NOTIFIER_HEAD(crypto_chain); |
| 35 | EXPORT_SYMBOL_GPL(crypto_chain); | 35 | EXPORT_SYMBOL_GPL(crypto_chain); |
| 36 | 36 | ||
| 37 | static inline struct crypto_alg *crypto_alg_get(struct crypto_alg *alg) | ||
| 38 | { | ||
| 39 | atomic_inc(&alg->cra_refcnt); | ||
| 40 | return alg; | ||
| 41 | } | ||
| 42 | |||
| 43 | struct crypto_alg *crypto_mod_get(struct crypto_alg *alg) | 37 | struct crypto_alg *crypto_mod_get(struct crypto_alg *alg) |
| 44 | { | 38 | { |
| 45 | return try_module_get(alg->cra_module) ? crypto_alg_get(alg) : NULL; | 39 | return try_module_get(alg->cra_module) ? crypto_alg_get(alg) : NULL; |
diff --git a/crypto/internal.h b/crypto/internal.h index 9ebedae3fb54..bd39bfc92eab 100644 --- a/crypto/internal.h +++ b/crypto/internal.h | |||
| @@ -103,6 +103,12 @@ int crypto_register_notifier(struct notifier_block *nb); | |||
| 103 | int crypto_unregister_notifier(struct notifier_block *nb); | 103 | int crypto_unregister_notifier(struct notifier_block *nb); |
| 104 | int crypto_probing_notify(unsigned long val, void *v); | 104 | int crypto_probing_notify(unsigned long val, void *v); |
| 105 | 105 | ||
| 106 | static inline struct crypto_alg *crypto_alg_get(struct crypto_alg *alg) | ||
| 107 | { | ||
| 108 | atomic_inc(&alg->cra_refcnt); | ||
| 109 | return alg; | ||
| 110 | } | ||
| 111 | |||
| 106 | static inline void crypto_alg_put(struct crypto_alg *alg) | 112 | static inline void crypto_alg_put(struct crypto_alg *alg) |
| 107 | { | 113 | { |
| 108 | if (atomic_dec_and_test(&alg->cra_refcnt) && alg->cra_destroy) | 114 | if (atomic_dec_and_test(&alg->cra_refcnt) && alg->cra_destroy) |
