From 361ab73305788c4bf35359a02d8873c36d654f1b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andrei=20Tudor=20C=C4=83lin?= Date: Sat, 21 Sep 2019 21:17:40 +0300 Subject: [PATCH] net: close correct file descriptor when netpoll registration fails In (*netFD).accept, if initializing the *netFD associated with the new connection fails, the listen FD is closed, rather than the FD associated with the new connection. Close the correct FD instead. Fixes #34392 Change-Id: I7bf3469d661e6d30cbd4b12f5f5fd330a81a541b Reviewed-on: https://go-review.googlesource.com/c/go/+/196778 Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- src/net/fd_unix.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/net/fd_unix.go b/src/net/fd_unix.go index dbe4a511ec..4f59871f49 100644 --- a/src/net/fd_unix.go +++ b/src/net/fd_unix.go @@ -248,7 +248,7 @@ func (fd *netFD) accept() (netfd *netFD, err error) { return nil, err } if err = netfd.init(); err != nil { - fd.Close() + netfd.Close() return nil, err } lsa, _ := syscall.Getsockname(netfd.pfd.Sysfd) -- 2.48.1