* [PATCH] trace-cmd: Close socket descriptor on failed connection
@ 2022-08-15 21:19 Steven Rostedt
0 siblings, 0 replies; only message in thread
From: Steven Rostedt @ 2022-08-15 21:19 UTC (permalink / raw)
To: Linux Trace Devel
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
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@goodmis.org>
---
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-08-16 5:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-15 21:19 [PATCH] trace-cmd: Close socket descriptor on failed connection Steven Rostedt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).