diff options
Diffstat (limited to 'crypto/rng.c')
-rw-r--r-- | crypto/rng.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/crypto/rng.c b/crypto/rng.c index 13155058b193..b81cffb13bab 100644 --- a/crypto/rng.c +++ b/crypto/rng.c | |||
@@ -155,14 +155,33 @@ EXPORT_SYMBOL_GPL(crypto_get_default_rng); | |||
155 | void crypto_put_default_rng(void) | 155 | void crypto_put_default_rng(void) |
156 | { | 156 | { |
157 | mutex_lock(&crypto_default_rng_lock); | 157 | mutex_lock(&crypto_default_rng_lock); |
158 | if (!--crypto_default_rng_refcnt) { | 158 | crypto_default_rng_refcnt--; |
159 | crypto_free_rng(crypto_default_rng); | ||
160 | crypto_default_rng = NULL; | ||
161 | } | ||
162 | mutex_unlock(&crypto_default_rng_lock); | 159 | mutex_unlock(&crypto_default_rng_lock); |
163 | } | 160 | } |
164 | EXPORT_SYMBOL_GPL(crypto_put_default_rng); | 161 | EXPORT_SYMBOL_GPL(crypto_put_default_rng); |
165 | 162 | ||
163 | #if defined(CONFIG_CRYPTO_RNG) || defined(CONFIG_CRYPTO_RNG_MODULE) | ||
164 | int crypto_del_default_rng(void) | ||
165 | { | ||
166 | int err = -EBUSY; | ||
167 | |||
168 | mutex_lock(&crypto_default_rng_lock); | ||
169 | if (crypto_default_rng_refcnt) | ||
170 | goto out; | ||
171 | |||
172 | crypto_free_rng(crypto_default_rng); | ||
173 | crypto_default_rng = NULL; | ||
174 | |||
175 | err = 0; | ||
176 | |||
177 | out: | ||
178 | mutex_unlock(&crypto_default_rng_lock); | ||
179 | |||
180 | return err; | ||
181 | } | ||
182 | EXPORT_SYMBOL_GPL(crypto_del_default_rng); | ||
183 | #endif | ||
184 | |||
166 | int crypto_register_rng(struct rng_alg *alg) | 185 | int crypto_register_rng(struct rng_alg *alg) |
167 | { | 186 | { |
168 | struct crypto_alg *base = &alg->base; | 187 | struct crypto_alg *base = &alg->base; |