diff options
author | Pauli <pauli@openssl.org> | 2023-06-22 09:28:57 +1000 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2023-07-01 21:18:25 +1000 |
commit | 495e6d3b6266176b92ea20dbc6541ca724fa07ff (patch) | |
tree | af7229f7eb07011ffb2d8d57ee8dee44d24a5a0a /crypto | |
parent | 9015cbb6eb7a50b04352d625e3907dfbb70684d0 (diff) | |
download | openssl-495e6d3b6266176b92ea20dbc6541ca724fa07ff.tar.gz |
dsa: update to structure based atomics
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21260)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/dsa/dsa_lib.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/crypto/dsa/dsa_lib.c b/crypto/dsa/dsa_lib.c index bcfd467b1c..03c4cb0c06 100644 --- a/crypto/dsa/dsa_lib.c +++ b/crypto/dsa/dsa_lib.c @@ -137,7 +137,6 @@ static DSA *dsa_new_intern(ENGINE *engine, OSSL_LIB_CTX *libctx) if (ret == NULL) return NULL; - ret->references = 1; ret->lock = CRYPTO_THREAD_lock_new(); if (ret->lock == NULL) { ERR_raise(ERR_LIB_DSA, ERR_R_CRYPTO_LIB); @@ -145,6 +144,9 @@ static DSA *dsa_new_intern(ENGINE *engine, OSSL_LIB_CTX *libctx) return NULL; } + if (!CRYPTO_NEW_REF(&ret->references, 1)) + goto err; + ret->libctx = libctx; ret->meth = DSA_get_default_method(); #if !defined(FIPS_MODULE) && !defined(OPENSSL_NO_ENGINE) @@ -210,7 +212,7 @@ void DSA_free(DSA *r) if (r == NULL) return; - CRYPTO_DOWN_REF(&r->references, &i, r->lock); + CRYPTO_DOWN_REF(&r->references, &i); REF_PRINT_COUNT("DSA", r); if (i > 0) return; @@ -227,6 +229,7 @@ void DSA_free(DSA *r) #endif CRYPTO_THREAD_lock_free(r->lock); + CRYPTO_FREE_REF(&r->references); ossl_ffc_params_cleanup(&r->params); BN_clear_free(r->pub_key); @@ -238,7 +241,7 @@ int DSA_up_ref(DSA *r) { int i; - if (CRYPTO_UP_REF(&r->references, &i, r->lock) <= 0) + if (CRYPTO_UP_REF(&r->references, &i) <= 0) return 0; REF_PRINT_COUNT("DSA", r); |