Skip to content

Commit 87b8f97

Browse files
committed
setupIO: close conn on error
While it does not make much sense practically, as runc is going to exit soon and all fds will be closed anyway, various linters (including SVACE) keep reporting this. Let's make them happy. Reported-by: Tigran Sogomonian <[email protected]> Reported-by: Mikhail Dmitrichenko <[email protected]> Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent 7d2161f commit 87b8f97

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

utils_linux.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func newProcess(p *specs.Process) (*libcontainer.Process, error) {
9595
}
9696

9797
// setupIO modifies the given process config according to the options.
98-
func setupIO(process *libcontainer.Process, container *libcontainer.Container, createTTY, detach bool, sockpath string) (*tty, error) {
98+
func setupIO(process *libcontainer.Process, container *libcontainer.Container, createTTY, detach bool, sockpath string) (_ *tty, Err error) {
9999
if createTTY {
100100
process.Stdin = nil
101101
process.Stdout = nil
@@ -121,6 +121,11 @@ func setupIO(process *libcontainer.Process, container *libcontainer.Container, c
121121
if err != nil {
122122
return nil, err
123123
}
124+
defer func() {
125+
if Err != nil {
126+
conn.Close()
127+
}
128+
}()
124129
t.postStart = append(t.postStart, conn)
125130
socket, err := conn.(*net.UnixConn).File()
126131
if err != nil {

0 commit comments

Comments
 (0)