summaryrefslogtreecommitdiffstats
path: root/crypto/provider_child.c
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2021-06-21 09:23:30 +0100
committerMatt Caswell <matt@openssl.org>2021-06-24 14:48:14 +0100
commit29aff653150c363be2d84f789a10b46d99d5cab9 (patch)
treec6aba738ee2873756bbb32419173955171e71fce /crypto/provider_child.c
parent352d482a2990cc04adff48aeda9c080d4a839f1e (diff)
Add a new provider to the store only after we activate it
Rather than creating the provider, adding to the store and then activating it, we do things the other way around, i.e. activate first and then add to the store. This means that the activation should occur before other threads are aware of the provider. Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15854)
Diffstat (limited to 'crypto/provider_child.c')
-rw-r--r--crypto/provider_child.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/crypto/provider_child.c b/crypto/provider_child.c
index 7ab161b795..e808eafe24 100644
--- a/crypto/provider_child.c
+++ b/crypto/provider_child.c
@@ -150,19 +150,21 @@ static int provider_create_child_cb(const OSSL_CORE_HANDLE *prov, void *cbdata)
1)) == NULL)
goto err;
- /*
- * We free the newly created ref. We rely on the provider sticking around
- * in the provider store.
- */
- ossl_provider_free(cprov);
-
if (!ossl_provider_activate(cprov, 0, 0))
goto err;
- if (!ossl_provider_set_child(cprov, prov)) {
+ if (!ossl_provider_set_child(cprov, prov)
+ || !ossl_provider_add_to_store(cprov)) {
ossl_provider_deactivate(cprov);
+ ossl_provider_free(cprov);
goto err;
}
+
+ /*
+ * We free the newly created ref. We rely on the provider sticking around
+ * in the provider store.
+ */
+ ossl_provider_free(cprov);
}
ret = 1;