qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] contrib/plugins: Close file descriptor on connect failure
@ 2023-10-16  9:31 Cong Liu
  2023-10-18  2:52 ` [PATCH v2] contrib/plugins: Close file descriptor on error return Cong Liu
  2023-10-23 13:44 ` [PATCH] contrib/plugins: Close file descriptor on connect failure Alex Bennée
  0 siblings, 2 replies; 4+ messages in thread
From: Cong Liu @ 2023-10-16  9:31 UTC (permalink / raw)
  To: Alex Bennée, Alexandre Iooss, Mahmoud Mandour; +Cc: Cong Liu, qemu-devel

This patch closes the file descriptor fd on connect failure to avoid
resource leak.

Signed-off-by: Cong Liu <liucong2@kylinos.cn>
---
 contrib/plugins/lockstep.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/contrib/plugins/lockstep.c b/contrib/plugins/lockstep.c
index f0cb8792c6fa..3c0f2b485181 100644
--- a/contrib/plugins/lockstep.c
+++ b/contrib/plugins/lockstep.c
@@ -303,6 +303,7 @@ static bool connect_socket(const char *path)
     sockaddr.sun_family = AF_UNIX;
     if (g_strlcpy(sockaddr.sun_path, path, pathlen) >= pathlen) {
         perror("bad path");
+        close(fd);
         return false;
     }
 
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-10-23 13:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-16  9:31 [PATCH] contrib/plugins: Close file descriptor on connect failure Cong Liu
2023-10-18  2:52 ` [PATCH v2] contrib/plugins: Close file descriptor on error return Cong Liu
2023-10-23 13:45   ` Alex Bennée
2023-10-23 13:44 ` [PATCH] contrib/plugins: Close file descriptor on connect failure Alex Bennée

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).