diff mbox series

[PULL,41/53] gdbstub: Prevent fd leakage

Message ID 20180531171606.21604-3-pbonzini@redhat.com
State New
Headers show
Series [PULL,01/53] sandbox: disable -sandbox if CONFIG_SECCOMP undefined | expand

Commit Message

Paolo Bonzini May 31, 2018, 5:15 p.m. UTC
From: Philippe Mathieu-Daudé <f4bug@amsat.org>

Since 2f652224f7, we now check if socket_set_nodelay() errored,
but forgot to close the socket before reporting an error.

Fixes: Coverity CID 1391290 (RESOURCE_LEAK)
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20180524223458.5651-1-f4bug@amsat.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 gdbstub.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/gdbstub.c b/gdbstub.c
index 6081e719c5..d6ab95006c 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -1842,6 +1842,7 @@  static bool gdb_accept(void)
     /* set short latency */
     if (socket_set_nodelay(fd)) {
         perror("setsockopt");
+        close(fd);
         return false;
     }