[PATCH 07/12] peer: NewPeer(): add missing device.mutex.Unlock() in error paths
Simon Ruderich
simon at ruderich.org
Mon Jan 1 11:52:57 CET 2018
---
src/peer.go | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/peer.go b/src/peer.go
index 228fe73..244bae0 100644
--- a/src/peer.go
+++ b/src/peer.go
@@ -83,6 +83,7 @@ func (device *Device) NewPeer(pk NoisePublicKey) (*Peer, error) {
// check if over limit
if len(device.peers) >= MaxPeers {
+ device.mutex.Unlock()
return nil, errors.New("Too many peers")
}
@@ -90,6 +91,7 @@ func (device *Device) NewPeer(pk NoisePublicKey) (*Peer, error) {
_, ok := device.peers[pk]
if ok {
+ device.mutex.Unlock()
return nil, errors.New("Adding existing peer")
}
device.peers[pk] = peer
--
2.15.1
More information about the WireGuard
mailing list