* [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* [PATCH v2] contrib/plugins: Close file descriptor on error return
2023-10-16 9:31 [PATCH] contrib/plugins: Close file descriptor on connect failure Cong Liu
@ 2023-10-18 2:52 ` 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
1 sibling, 1 reply; 4+ messages in thread
From: Cong Liu @ 2023-10-18 2:52 UTC (permalink / raw)
To: liucong2, Alex Bennée, Alexandre Iooss, Mahmoud Mandour; +Cc: qemu-devel
This patch closes the file descriptor fd on error return to avoid
resource leak.
Fixes: ec7ee95db909 ("contrib/plugins: fix coverity warning in lockstep")
Signed-off-by: Cong Liu <liucong2@kylinos.cn>
---
contrib/plugins/lockstep.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/contrib/plugins/lockstep.c b/contrib/plugins/lockstep.c
index f0cb8792c6fa..237543b43a76 100644
--- a/contrib/plugins/lockstep.c
+++ b/contrib/plugins/lockstep.c
@@ -257,6 +257,7 @@ static bool setup_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;
}
@@ -303,6 +304,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* Re: [PATCH v2] contrib/plugins: Close file descriptor on error return
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
0 siblings, 0 replies; 4+ messages in thread
From: Alex Bennée @ 2023-10-23 13:45 UTC (permalink / raw)
To: Cong Liu; +Cc: Alexandre Iooss, Mahmoud Mandour, qemu-devel
Cong Liu <liucong2@kylinos.cn> writes:
> This patch closes the file descriptor fd on error return to avoid
> resource leak.
>
> Fixes: ec7ee95db909 ("contrib/plugins: fix coverity warning in lockstep")
> Signed-off-by: Cong Liu <liucong2@kylinos.cn>
> ---
> contrib/plugins/lockstep.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/contrib/plugins/lockstep.c b/contrib/plugins/lockstep.c
> index f0cb8792c6fa..237543b43a76 100644
> --- a/contrib/plugins/lockstep.c
> +++ b/contrib/plugins/lockstep.c
> @@ -257,6 +257,7 @@ static bool setup_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;
> }
>
> @@ -303,6 +304,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;
> }
Sorry queued this version to plugins/next, thanks.
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] contrib/plugins: Close file descriptor on connect failure
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:44 ` Alex Bennée
1 sibling, 0 replies; 4+ messages in thread
From: Alex Bennée @ 2023-10-23 13:44 UTC (permalink / raw)
To: Cong Liu; +Cc: Alexandre Iooss, Mahmoud Mandour, qemu-devel
Cong Liu <liucong2@kylinos.cn> writes:
> 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;
> }
Queued to plugins/next, thanks.
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
^ permalink raw reply [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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.