diff mbox

net/socket.c: Fix fd leak in net_socket_listen_init() error paths

Message ID 1324770431-6074-1-git-send-email-peter.maydell@linaro.org
State Accepted
Commit a46667ea29218565473e430ceae62e2838f6ce3f
Headers show

Commit Message

Peter Maydell Dec. 24, 2011, 11:47 p.m. UTC
Fix a leak of a file descriptor due to missing closesocket() calls
in error paths in net_socket_listen_init().

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
Coverity again...

 net/socket.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Comments

Stefan Hajnoczi Jan. 3, 2012, 10:51 a.m. UTC | #1
On Sat, Dec 24, 2011 at 11:47:11PM +0000, Peter Maydell wrote:
> Fix a leak of a file descriptor due to missing closesocket() calls
> in error paths in net_socket_listen_init().
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> Coverity again...
> 
>  net/socket.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)

Thanks, applied to the trivial patches -next tree:
https://github.com/stefanha/qemu/commits/trivial-patches-next

Stefan
diff mbox

Patch

diff --git a/net/socket.c b/net/socket.c
index aaf9be4..c9d70d3 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -427,12 +427,14 @@  static int net_socket_listen_init(VLANState *vlan,
     if (ret < 0) {
         perror("bind");
         g_free(s);
+        closesocket(fd);
         return -1;
     }
     ret = listen(fd, 0);
     if (ret < 0) {
         perror("listen");
         g_free(s);
+        closesocket(fd);
         return -1;
     }
     s->vlan = vlan;