All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] plugins: Fix some resource leaks
@ 2020-11-09  8:28 Alex Chen
  2020-11-09  8:28 ` [PATCH v3 1/2] plugins: Fix resource leak in connect_socket() Alex Chen
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Alex Chen @ 2020-11-09  8:28 UTC (permalink / raw)
  To: alex.bennee, mjt, laurent
  Cc: alex.chen, qemu-trivial, qemu-devel, zhengchuan, zhang.zhanghailiang

There are 3 resource leaks in contrib/plugins/lockstep.c, fix it.

v2->v3:
- change the "From" line to "Alex Chen"

v1->v2:
- add the cover letter
- modify the subject of the patch[2/2]

Alex Chen (2):
  plugins: Fix resource leak in connect_socket()
  plugins: Fix two resource leaks in setup_socket()

 contrib/plugins/lockstep.c | 3 +++
 1 file changed, 3 insertions(+)

-- 
2.19.1



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

* [PATCH v3 1/2] plugins: Fix resource leak in connect_socket()
  2020-11-09  8:28 [PATCH v3 0/2] plugins: Fix some resource leaks Alex Chen
@ 2020-11-09  8:28 ` Alex Chen
  2020-11-09  8:28 ` [PATCH v3 2/2] plugins: Fix two resource leaks in setup_socket() Alex Chen
  2020-11-10 11:54 ` [PATCH v3 0/2] plugins: Fix some resource leaks Alex Bennée
  2 siblings, 0 replies; 4+ messages in thread
From: Alex Chen @ 2020-11-09  8:28 UTC (permalink / raw)
  To: alex.bennee, mjt, laurent
  Cc: alex.chen, qemu-trivial, qemu-devel, zhengchuan, zhang.zhanghailiang

Close the fd when the connect() fails.

Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: Alex Chen <alex.chen@huawei.com>
---
 contrib/plugins/lockstep.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/contrib/plugins/lockstep.c b/contrib/plugins/lockstep.c
index a696673dff..319bd44b83 100644
--- a/contrib/plugins/lockstep.c
+++ b/contrib/plugins/lockstep.c
@@ -292,6 +292,7 @@ static bool connect_socket(const char *path)
 
     if (connect(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr)) < 0) {
         perror("failed to connect");
+        close(fd);
         return false;
     }
 
-- 
2.19.1



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

* [PATCH v3 2/2] plugins: Fix two resource leaks in setup_socket()
  2020-11-09  8:28 [PATCH v3 0/2] plugins: Fix some resource leaks Alex Chen
  2020-11-09  8:28 ` [PATCH v3 1/2] plugins: Fix resource leak in connect_socket() Alex Chen
@ 2020-11-09  8:28 ` Alex Chen
  2020-11-10 11:54 ` [PATCH v3 0/2] plugins: Fix some resource leaks Alex Bennée
  2 siblings, 0 replies; 4+ messages in thread
From: Alex Chen @ 2020-11-09  8:28 UTC (permalink / raw)
  To: alex.bennee, mjt, laurent
  Cc: alex.chen, qemu-trivial, qemu-devel, zhengchuan, zhang.zhanghailiang

Either accept() fails or exits normally, we need to close the fd.

Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: Alex Chen <alex.chen@huawei.com>
---
 contrib/plugins/lockstep.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/contrib/plugins/lockstep.c b/contrib/plugins/lockstep.c
index 319bd44b83..5aad50869d 100644
--- a/contrib/plugins/lockstep.c
+++ b/contrib/plugins/lockstep.c
@@ -268,11 +268,13 @@ static bool setup_socket(const char *path)
     socket_fd = accept(fd, NULL, NULL);
     if (socket_fd < 0 && errno != EINTR) {
         perror("accept socket");
+        close(fd);
         return false;
     }
 
     qemu_plugin_outs("setup_socket::ready\n");
 
+    close(fd);
     return true;
 }
 
-- 
2.19.1



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

* Re: [PATCH v3 0/2] plugins: Fix some resource leaks
  2020-11-09  8:28 [PATCH v3 0/2] plugins: Fix some resource leaks Alex Chen
  2020-11-09  8:28 ` [PATCH v3 1/2] plugins: Fix resource leak in connect_socket() Alex Chen
  2020-11-09  8:28 ` [PATCH v3 2/2] plugins: Fix two resource leaks in setup_socket() Alex Chen
@ 2020-11-10 11:54 ` Alex Bennée
  2 siblings, 0 replies; 4+ messages in thread
From: Alex Bennée @ 2020-11-10 11:54 UTC (permalink / raw)
  To: Alex Chen
  Cc: zhang.zhanghailiang, qemu-trivial, mjt, laurent, qemu-devel, zhengchuan


Alex Chen <alex.chen@huawei.com> writes:

> There are 3 resource leaks in contrib/plugins/lockstep.c, fix it.

Queued to for-5.2/various-fixes, thanks.

>
> v2->v3:
> - change the "From" line to "Alex Chen"
>
> v1->v2:
> - add the cover letter
> - modify the subject of the patch[2/2]
>
> Alex Chen (2):
>   plugins: Fix resource leak in connect_socket()
>   plugins: Fix two resource leaks in setup_socket()
>
>  contrib/plugins/lockstep.c | 3 +++
>  1 file changed, 3 insertions(+)


-- 
Alex Bennée


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

end of thread, other threads:[~2020-11-10 11:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-09  8:28 [PATCH v3 0/2] plugins: Fix some resource leaks Alex Chen
2020-11-09  8:28 ` [PATCH v3 1/2] plugins: Fix resource leak in connect_socket() Alex Chen
2020-11-09  8:28 ` [PATCH v3 2/2] plugins: Fix two resource leaks in setup_socket() Alex Chen
2020-11-10 11:54 ` [PATCH v3 0/2] plugins: Fix some resource leaks 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.