From 7a761528abadea4e5c1be8fe8d73c8538f55cdee Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 12 Oct 2017 02:31:11 +0200 Subject: noise: no need to take the RCU lock if we're not dereferencing Signed-off-by: Jason A. Donenfeld --- src/noise.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/noise.c b/src/noise.c index 72b57cc..8e4f2a6 100644 --- a/src/noise.c +++ b/src/noise.c @@ -187,10 +187,8 @@ bool noise_received_with_keypair(struct noise_keypairs *keypairs, struct noise_k bool key_is_new; struct noise_keypair *old_keypair; - /* We first check without taking the spinlock but just RCU. */ - rcu_read_lock_bh(); - key_is_new = received_keypair == rcu_dereference_bh(keypairs->next_keypair); - rcu_read_unlock_bh(); + /* We first check without taking the spinlock. */ + key_is_new = received_keypair == rcu_access_pointer(keypairs->next_keypair); if (likely(!key_is_new)) return false; -- cgit v1.2.3