diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2016-11-02 06:32:03 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2016-11-02 06:32:03 +0100 |
commit | 303ac6d412b4578cbe74c884aa81138cb45d9625 (patch) | |
tree | 425f3ce2583a439d34bc0bd9c0f5a73941c3b6a5 /src/peer.c | |
parent | data: do not allow usage of keypair just before hash removal (diff) | |
download | wireguard-monolithic-historical-303ac6d412b4578cbe74c884aa81138cb45d9625.tar.xz wireguard-monolithic-historical-303ac6d412b4578cbe74c884aa81138cb45d9625.zip |
kref: elide checks
Diffstat (limited to 'src/peer.c')
-rw-r--r-- | src/peer.c | 8 |
1 files changed, 3 insertions, 5 deletions
@@ -44,16 +44,14 @@ 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 (unlikely(!peer)) - return NULL; - if (unlikely(!kref_get_unless_zero(&peer->refcount))) + if (unlikely(!peer || !kref_get_unless_zero(&peer->refcount))) return NULL; return peer; } void peer_remove(struct wireguard_peer *peer) { - if (!peer) + if (unlikely(!peer)) return; lockdep_assert_held(&peer->device->device_update_lock); @@ -88,7 +86,7 @@ static void kref_release(struct kref *refcount) void peer_put(struct wireguard_peer *peer) { - if (!peer) + if (unlikely(!peer)) return; kref_put(&peer->refcount, kref_release); } |