diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2016-11-01 20:01:59 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2016-11-01 20:01:59 +0100 |
commit | aff3b3029c319dbc39fb56b301cc6688b59d7d4b (patch) | |
tree | f279155475f506bb62f060e0f971e0bd7dbf2184 /src/peer.c | |
parent | compat: grsecurity backports get_random_long (diff) | |
download | wireguard-monolithic-historical-aff3b3029c319dbc39fb56b301cc6688b59d7d4b.tar.xz wireguard-monolithic-historical-aff3b3029c319dbc39fb56b301cc6688b59d7d4b.zip |
peer: kref is most likely to succeed
Diffstat (limited to 'src/peer.c')
-rw-r--r-- | src/peer.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -44,9 +44,9 @@ struct wireguard_peer *peer_create(struct wireguard_device *wg, const u8 public_ struct wireguard_peer *peer_get(struct wireguard_peer *peer) { RCU_LOCKDEP_WARN(!rcu_read_lock_held(), "Calling peer_get without holding the RCU read lock."); - if (!peer) + if (unlikely(!peer)) return NULL; - if (!kref_get_unless_zero(&peer->refcount)) + if (unlikely(!kref_get_unless_zero(&peer->refcount))) return NULL; return peer; } |