From 390f9bad69ce19f601abf131ceabf90aedc0d3d5 Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Wed, 16 Dec 2020 15:15:06 +0100 Subject: CORE: Separate OSSL_PROVIDER activation from OSSL_PROVIDER reference This introduces a separate activation counter, and the function ossl_provider_deactivate() for provider deactivation. Something to be noted is that if the reference count goes down to zero, we don't care if the activation count is non-zero (i.e. someone forgot to call ossl_provider_deactivate()). Since there are no more references to the provider, it doesn't matter. The important thing is that deactivation doesn't remove the provider as long as there are references to it, for example because there are live methods associated with that provider, but still makes the provider unavailable to create new methods from. Fixes #13503 Fixes #12157 Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/13661) --- crypto/provider.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'crypto/provider.c') diff --git a/crypto/provider.c b/crypto/provider.c index 0441fb2f2a..bd8f75a2c1 100644 --- a/crypto/provider.c +++ b/crypto/provider.c @@ -40,6 +40,8 @@ OSSL_PROVIDER *OSSL_PROVIDER_load(OSSL_LIB_CTX *libctx, const char *name) int OSSL_PROVIDER_unload(OSSL_PROVIDER *prov) { + if (!ossl_provider_deactivate(prov)) + return 0; ossl_provider_free(prov); return 1; } -- cgit v1.2.3