Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
qemu: Don't leak file descriptors in case of error
Browse files Browse the repository at this point in the history
If we take one of the error paths from setupVirtiofsd() after
opening the fd variable, the fd.Close() function is not called.

Fixes: #2683

Signed-off-by: Christophe de Dinechin <[email protected]>
  • Loading branch information
c3d committed May 13, 2020
1 parent 80bd453 commit 7b269ff
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions virtcontainers/qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,7 @@ func (q *qemu) setupVirtiofsd() (err error) {
if err != nil {
return err
}
defer fd.Close()

const sockFd = 3 // Cmd.ExtraFiles[] fds are numbered starting from 3
cmd := exec.Command(q.config.VirtioFSDaemon, q.virtiofsdArgs(sockFd)...)
Expand Down

0 comments on commit 7b269ff

Please sign in to comment.