From: "Steven Rostedt (Google)" <rostedt@xxxxxxxxxxx> In trace_vsock_open(), if the connection fails, the sd file descriptor still needs to be closed. Fixes: 76aaeb474 ("trace-cmd: Add VM kernel tracing over vsockets transport") Signed-off-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx> --- tracecmd/trace-vsock.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tracecmd/trace-vsock.c b/tracecmd/trace-vsock.c index 3bad9efad39a..baa310f7586b 100644 --- a/tracecmd/trace-vsock.c +++ b/tracecmd/trace-vsock.c @@ -19,8 +19,10 @@ int __hidden trace_vsock_open(unsigned int cid, unsigned int port) if (sd < 0) return -errno; - if (connect(sd, (struct sockaddr *)&addr, sizeof(addr))) + if (connect(sd, (struct sockaddr *)&addr, sizeof(addr))) { + close(sd); return -errno; + } return sd; } -- 2.35.1