]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Some minor nit corrections in the thread code for rcu
authorNeil Horman <nhorman@openssl.org>
Mon, 17 Jun 2024 18:12:46 +0000 (14:12 -0400)
committerTomas Mraz <tomas@openssl.org>
Thu, 20 Jun 2024 14:54:40 +0000 (16:54 +0200)
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/24630)

crypto/threads_none.c
crypto/threads_pthread.c
crypto/threads_win.c
test/threadstest.c

index 47a7c01f26aa274b3e2a4ccc066d0486d1e4db00..66ef99f497a794d4808cb81ca2c2ffe8868acdec 100644 (file)
@@ -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;
 
index 358882ce0a97b25e386f2c987bf26204eab6931b..dda6893b013d56f5ced6bf50fd633d5dc70e8030 100644 (file)
@@ -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)
index 60c18d4313d9776207a5c5f62f741010d3591373..bc430ef1b9e6c36e860af92b46a0742583ce7b4d 100644 (file)
@@ -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)
index 5858fbdf82f348659632480ec76cb70beae04e7c..2712df7f47ecf04b3cc6adcd0cb8e1c18b7ad22b 100644 (file)
@@ -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();