From: Colin Adler Date: Tue, 13 Sep 2022 03:03:55 +0000 (-0500) Subject: tun/netstack: ensure `(*netTun).incomingPacket` chan is closed X-Git-Tag: 0.0.20230223~7 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=fde0a9525ae5be7f6356a410f1bfc52ecc720f85;p=thirdparty%2Fwireguard-go.git tun/netstack: ensure `(*netTun).incomingPacket` chan is closed Without this, `device.Close()` will deadlock. Signed-off-by: Colin Adler Signed-off-by: Jason A. Donenfeld --- diff --git a/tun/netstack/tun.go b/tun/netstack/tun.go index b0e7b70..f232ca3 100644 --- a/tun/netstack/tun.go +++ b/tun/netstack/tun.go @@ -164,6 +164,10 @@ func (tun *netTun) Close() error { tun.ep.Close() + if tun.incomingPacket != nil { + close(tun.incomingPacket) + } + return nil }