]> git.ipfire.org Git - thirdparty/wireguard-go.git/commitdiff
tun: linux: netlink sock needs cleaning up but file will be gc'd
authorJason A. Donenfeld <Jason@zx2c4.com>
Wed, 27 Feb 2019 01:20:17 +0000 (02:20 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Wed, 27 Feb 2019 03:11:41 +0000 (04:11 +0100)
tun/tun_linux.go

index 8dcad6b6f8d3b42feb592c2a1153e343061ab82e..0ee9f6c63ad164afcd587be3b19b82cfbef68e03 100644 (file)
@@ -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
        }