diff mbox series

[v3,02/10] char: do not double-close fd when failing to add client

Message ID 20230207142535.1153722-3-marcandre.lureau@redhat.com
State New
Headers show
Series Teach 'getfd' QMP command to import win32 sockets | expand

Commit Message

Marc-André Lureau Feb. 7, 2023, 2:25 p.m. UTC
From: Marc-André Lureau <marcandre.lureau@redhat.com>

The caller is already closing the fd on failure.

Fixes: c3054a6e6a ("char: Factor out qmp_add_client() parts and move to chardev/")
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 chardev/char.c | 2 --
 1 file changed, 2 deletions(-)

Comments

Thomas Huth Feb. 7, 2023, 2:43 p.m. UTC | #1
On 07/02/2023 15.25, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
> 
> The caller is already closing the fd on failure.
> 
> Fixes: c3054a6e6a ("char: Factor out qmp_add_client() parts and move to chardev/")
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   chardev/char.c | 2 --
>   1 file changed, 2 deletions(-)
> 
> diff --git a/chardev/char.c b/chardev/char.c
> index 11eab7764c..e69390601f 100644
> --- a/chardev/char.c
> +++ b/chardev/char.c
> @@ -1175,12 +1175,10 @@ bool qmp_add_client_char(int fd, bool has_skipauth, bool skipauth,
>   
>       if (!s) {
>           error_setg(errp, "protocol '%s' is invalid", protocol);
> -        close(fd);
>           return false;
>       }
>       if (qemu_chr_add_client(s, fd) < 0) {
>           error_setg(errp, "failed to add client");
> -        close(fd);
>           return false;
>       }
>       return true;

Reviewed-by: Thomas Huth <thuth@redhat.com>
diff mbox series

Patch

diff --git a/chardev/char.c b/chardev/char.c
index 11eab7764c..e69390601f 100644
--- a/chardev/char.c
+++ b/chardev/char.c
@@ -1175,12 +1175,10 @@  bool qmp_add_client_char(int fd, bool has_skipauth, bool skipauth,
 
     if (!s) {
         error_setg(errp, "protocol '%s' is invalid", protocol);
-        close(fd);
         return false;
     }
     if (qemu_chr_add_client(s, fd) < 0) {
         error_setg(errp, "failed to add client");
-        close(fd);
         return false;
     }
     return true;