From: Neil Horman Date: Mon, 17 Jun 2024 18:12:46 +0000 (-0400) Subject: Some minor nit corrections in the thread code for rcu X-Git-Tag: openssl-3.3.2~118 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d38d2642287ef9a22f20e662a19c217c227043a6;p=thirdparty%2Fopenssl.git Some minor nit corrections in the thread code for rcu Reviewed-by: Paul Dale Reviewed-by: Matt Caswell Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/24630) --- diff --git a/crypto/threads_none.c b/crypto/threads_none.c index 47a7c01f26a..66ef99f497a 100644 --- a/crypto/threads_none.c +++ b/crypto/threads_none.c @@ -23,7 +23,8 @@ struct rcu_lock_st { struct rcu_cb_item *cb_items; }; -CRYPTO_RCU_LOCK *ossl_rcu_lock_new(int num_writers, OSSL_LIB_CTX *ctx) +CRYPTO_RCU_LOCK *ossl_rcu_lock_new(int num_writers, + ossl_unused OSSL_LIB_CTX *ctx) { struct rcu_lock_st *lock; diff --git a/crypto/threads_pthread.c b/crypto/threads_pthread.c index 358882ce0a9..dda6893b013 100644 --- a/crypto/threads_pthread.c +++ b/crypto/threads_pthread.c @@ -391,7 +391,9 @@ static void ossl_rcu_free_local_data(void *arg) OSSL_LIB_CTX *ctx = arg; CRYPTO_THREAD_LOCAL *lkey = ossl_lib_ctx_get_rcukey(ctx); struct rcu_thr_data *data = CRYPTO_THREAD_get_local(lkey); + OPENSSL_free(data); + CRYPTO_THREAD_set_local(lkey, NULL); } void ossl_rcu_read_lock(CRYPTO_RCU_LOCK *lock) diff --git a/crypto/threads_win.c b/crypto/threads_win.c index 60c18d4313d..bc430ef1b9e 100644 --- a/crypto/threads_win.c +++ b/crypto/threads_win.c @@ -190,6 +190,7 @@ static void ossl_rcu_free_local_data(void *arg) CRYPTO_THREAD_LOCAL *lkey = ossl_lib_ctx_get_rcukey(ctx); struct rcu_thr_data *data = CRYPTO_THREAD_get_local(lkey); OPENSSL_free(data); + CRYPTO_THREAD_set_local(lkey, NULL); } void ossl_rcu_read_lock(CRYPTO_RCU_LOCK *lock) diff --git a/test/threadstest.c b/test/threadstest.c index 5858fbdf82f..2712df7f47e 100644 --- a/test/threadstest.c +++ b/test/threadstest.c @@ -436,6 +436,8 @@ static int _torture_rcu(void) rcu_torture_result = 1; rcu_lock = ossl_rcu_lock_new(1, NULL); + if (rcu_lock == NULL) + goto out; TEST_info("Staring rcu torture"); t1 = ossl_time_now();