Cleanup socket in lisafs gofer's BindAt handler on error paths.

Otherwise, we leak will leak the un-closed FD.

PiperOrigin-RevId: 473294586
This commit is contained in:
Ayush Ranjan
2022-09-09 11:07:25 -07:00
committed by gVisor bot
parent 5819462d8f
commit ecda533559
+2
View File
@@ -690,12 +690,14 @@ func (fd *controlFDLisa) BindAt(name string, sockType uint32) (*lisafs.ControlFD
return nil, linux.Statx{}, nil, -1, err
}
if err := unix.Bind(sockFD, &unix.SockaddrUnix{Name: socketPath}); err != nil {
_ = unix.Close(sockFD)
return nil, linux.Statx{}, nil, -1, err
}
// Stat the socket.
sockStat, err := fstatTo(sockFD)
if err != nil {
_ = unix.Close(sockFD)
_ = unix.Unlink(socketPath)
return nil, linux.Statx{}, nil, -1, err
}