mirror of
https://github.com/openssl/openssl.git
synced 2025-01-30 14:01:55 +08:00
Ensure we deregister thread handlers even after a failed init
If we attempt to init a provider but that init fails, then we should still deregister any thread handlers. The provider may have failed after these were registered. Fixes #13338 Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14576)
This commit is contained in:
parent
7e7e034a10
commit
ee067bc066
@ -359,9 +359,6 @@ void ossl_provider_free(OSSL_PROVIDER *prov)
|
|||||||
*/
|
*/
|
||||||
if (ref == 0) {
|
if (ref == 0) {
|
||||||
if (prov->flag_initialized) {
|
if (prov->flag_initialized) {
|
||||||
#ifndef FIPS_MODULE
|
|
||||||
ossl_init_thread_deregister(prov);
|
|
||||||
#endif
|
|
||||||
if (prov->teardown != NULL)
|
if (prov->teardown != NULL)
|
||||||
prov->teardown(prov->provctx);
|
prov->teardown(prov->provctx);
|
||||||
#ifndef OPENSSL_NO_ERR
|
#ifndef OPENSSL_NO_ERR
|
||||||
@ -380,6 +377,12 @@ void ossl_provider_free(OSSL_PROVIDER *prov)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef FIPS_MODULE
|
#ifndef FIPS_MODULE
|
||||||
|
/*
|
||||||
|
* We deregister thread handling whether or not the provider was
|
||||||
|
* initialized. If init was attempted but was not successful then
|
||||||
|
* the provider may still have registered a thread handler.
|
||||||
|
*/
|
||||||
|
ossl_init_thread_deregister(prov);
|
||||||
DSO_free(prov->module);
|
DSO_free(prov->module);
|
||||||
#endif
|
#endif
|
||||||
OPENSSL_free(prov->name);
|
OPENSSL_free(prov->name);
|
||||||
@ -561,10 +564,6 @@ static int provider_init(OSSL_PROVIDER *prov)
|
|||||||
&provider_dispatch, &tmp_provctx)) {
|
&provider_dispatch, &tmp_provctx)) {
|
||||||
ERR_raise_data(ERR_LIB_CRYPTO, ERR_R_INIT_FAIL,
|
ERR_raise_data(ERR_LIB_CRYPTO, ERR_R_INIT_FAIL,
|
||||||
"name=%s", prov->name);
|
"name=%s", prov->name);
|
||||||
#ifndef FIPS_MODULE
|
|
||||||
DSO_free(prov->module);
|
|
||||||
prov->module = NULL;
|
|
||||||
#endif
|
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
prov->provctx = tmp_provctx;
|
prov->provctx = tmp_provctx;
|
||||||
|
Loading…
Reference in New Issue
Block a user