aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/peer.h
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-08-01 15:35:42 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-08-01 19:24:04 +0200
commit13f19049ed1e19b26e80e0b549744a4ca2c44443 (patch)
tree421deb4f6d06a1d90acd9b5326a9ec583d5b0d86 /src/peer.h
parentallowedips: free root inside of RCU callback (diff)
downloadwireguard-monolithic-historical-13f19049ed1e19b26e80e0b549744a4ca2c44443.tar.xz
wireguard-monolithic-historical-13f19049ed1e19b26e80e0b549744a4ca2c44443.zip
queueing: keep reference to peer after setting atomic state bit
After we atomic_set, the peer is allowed to be freed, which means if we want to continue to reference it, we need to bump the reference count. This was introduced a few commits ago by b713ab0e when implementing some simplification suggestions.
Diffstat (limited to 'src/peer.h')
-rw-r--r--src/peer.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/peer.h b/src/peer.h
index 70120ee..059fa64 100644
--- a/src/peer.h
+++ b/src/peer.h
@@ -63,9 +63,10 @@ struct wireguard_peer {
struct wireguard_peer *peer_create(struct wireguard_device *wg, const u8 public_key[NOISE_PUBLIC_KEY_LEN], const u8 preshared_key[NOISE_SYMMETRIC_KEY_LEN]);
struct wireguard_peer * __must_check peer_get_maybe_zero(struct wireguard_peer *peer);
-static inline void peer_get(struct wireguard_peer *peer)
+static inline struct wireguard_peer *peer_get(struct wireguard_peer *peer)
{
kref_get(&peer->refcount);
+ return peer;
}
void peer_put(struct wireguard_peer *peer);
void peer_remove(struct wireguard_peer *peer);