summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crypto/provider_core.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/crypto/provider_core.c b/crypto/provider_core.c
index 1b16b27905..6b2a98524d 100644
--- a/crypto/provider_core.c
+++ b/crypto/provider_core.c
@@ -1111,7 +1111,14 @@ static int provider_deactivate(OSSL_PROVIDER *prov, int upcalls,
return -1;
}
- CRYPTO_atomic_add(&prov->activatecnt, -1, &count, prov->activatecnt_lock);
+ if (!CRYPTO_atomic_add(&prov->activatecnt, -1, &count, prov->activatecnt_lock)) {
+ if (lock) {
+ CRYPTO_THREAD_unlock(prov->flag_lock);
+ CRYPTO_THREAD_unlock(store->lock);
+ }
+ return -1;
+ }
+
#ifndef FIPS_MODULE
if (count >= 1 && prov->ischild && upcalls) {
/*