diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-10-12 02:31:11 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-10-17 19:26:07 +0200 |
commit | 2a3f8e6f19c84ab9180c74c21c59f39f319a7e4a (patch) | |
tree | 278c4d6f6a41691ccc98dfb7ca80a397305ce09b /src/noise.c | |
parent | compat: just make ro_after_init read_mostly (diff) | |
download | wireguard-monolithic-historical-2a3f8e6f19c84ab9180c74c21c59f39f319a7e4a.tar.xz wireguard-monolithic-historical-2a3f8e6f19c84ab9180c74c21c59f39f319a7e4a.zip |
noise: no need to take the RCU lock if we're not dereferencing
Diffstat (limited to 'src/noise.c')
-rw-r--r-- | src/noise.c | 6 |
1 files 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; |