[openssl] master update
Richard Levitte
levitte at openssl.org
Thu Mar 14 15:22:40 UTC 2019
The branch master has been updated
via 085bef9f7cee8506cc9d438d4fbc3663f46c5fe2 (commit)
from ee633ace7397ebc9829b845e7e7bbd8283b455f6 (commit)
- Log -----------------------------------------------------------------
commit 085bef9f7cee8506cc9d438d4fbc3663f46c5fe2
Author: Richard Levitte <levitte at openssl.org>
Date: Thu Mar 14 07:59:28 2019 +0100
crypto/provider_core.c: correct definition and use of lock
Fixes #8476
Reviewed-by: Matt Caswell <matt at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8477)
-----------------------------------------------------------------------
Summary of changes:
crypto/provider_core.c | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
diff --git a/crypto/provider_core.c b/crypto/provider_core.c
index fb4be55..8af5b1f1 100644
--- a/crypto/provider_core.c
+++ b/crypto/provider_core.c
@@ -28,9 +28,7 @@ struct ossl_provider_st {
/* OpenSSL library side data */
CRYPTO_REF_COUNT refcnt;
-#ifndef HAVE_ATOMICS
- CRYPTO_RWLOCK refcnt_lock; /* For the ref counter */
-#endif
+ CRYPTO_RWLOCK *refcnt_lock; /* For the ref counter */
char *name;
DSO *module;
OSSL_provider_init_fn *init_function;
@@ -123,11 +121,7 @@ int ossl_provider_upref(OSSL_PROVIDER *prov)
{
int ref = 0;
-#ifndef HAVE_ATOMICS
CRYPTO_UP_REF(&prov->refcnt, &ref, prov->refcnt_lock);
-#else
- CRYPTO_UP_REF(&prov->refcnt, &ref, NULL);
-#endif
return ref;
}
@@ -171,6 +165,9 @@ OSSL_PROVIDER *ossl_provider_new(OPENSSL_CTX *libctx, const char *name,
}
if ((prov = OPENSSL_zalloc(sizeof(*prov))) == NULL
+#ifndef HAVE_ATOMICS
+ || (prov->refcnt_lock = CRYPTO_THREAD_lock_new()) == NULL
+#endif
|| !ossl_provider_upref(prov) /* +1 One reference to be returned */
|| (prov->name = OPENSSL_strdup(name)) == NULL) {
ossl_provider_free(prov);
@@ -207,11 +204,7 @@ void ossl_provider_free(OSSL_PROVIDER *prov)
if (prov != NULL) {
int ref = 0;
-#ifndef HAVE_ATOMICS
- CRYPTO_DOWN_REF(&prov->refcnt, &ref, provider_lock);
-#else
- CRYPTO_DOWN_REF(&prov->refcnt, &ref, NULL);
-#endif
+ CRYPTO_DOWN_REF(&prov->refcnt, &ref, prov->refcnt_lock);
/*
* When the refcount drops down to one, there is only one reference,
@@ -231,6 +224,9 @@ void ossl_provider_free(OSSL_PROVIDER *prov)
if (ref == 0) {
DSO_free(prov->module);
OPENSSL_free(prov->name);
+#ifndef HAVE_ATOMICS
+ CRYPTO_THREAD_lock_free(prov->refcnt_lock);
+#endif
OPENSSL_free(prov);
}
}
More information about the openssl-commits
mailing list