From a46667ea29218565473e430ceae62e2838f6ce3f Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Sat, 24 Dec 2011 23:47:11 +0000 Subject: [PATCH] net/socket.c: Fix fd leak in net_socket_listen_init() error paths 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 Signed-off-by: Stefan Hajnoczi --- net/socket.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/socket.c b/net/socket.c index aaf9be48e2..c9d70d388e 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; -- GitLab