Commit 361ab733 authored by Andrei Tudor Călin's avatar Andrei Tudor Călin Committed by Ian Lance Taylor

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 <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent 20f0bcb0
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment