From: Jason A. Donenfeld Date: Wed, 27 Feb 2019 01:20:17 +0000 (+0100) Subject: tun: linux: netlink sock needs cleaning up but file will be gc'd X-Git-Tag: 0.0.20190409~47 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=971be13e773f133a0a5ab08957725b43452202e2;p=thirdparty%2Fwireguard-go.git tun: linux: netlink sock needs cleaning up but file will be gc'd --- diff --git a/tun/tun_linux.go b/tun/tun_linux.go index 8dcad6b..0ee9f6c 100644 --- a/tun/tun_linux.go +++ b/tun/tun_linux.go @@ -390,7 +390,6 @@ func CreateTUNFromFile(file *os.File, mtu int) (TUNDevice, error) { _, err = tun.Name() if err != nil { - tun.tunFile.Close() return nil, err } @@ -403,12 +402,11 @@ func CreateTUNFromFile(file *os.File, mtu int) (TUNDevice, error) { tun.netlinkSock, err = createNetlinkSocket() if err != nil { - tun.tunFile.Close() return nil, err } tun.netlinkCancel, err = rwcancel.NewRWCancel(tun.netlinkSock) if err != nil { - tun.tunFile.Close() + unix.Close(tun.netlinkSock) return nil, err } @@ -418,7 +416,7 @@ func CreateTUNFromFile(file *os.File, mtu int) (TUNDevice, error) { err = tun.setMTU(mtu) if err != nil { - tun.Close() + unix.Close(tun.netlinkSock) return nil, err }