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 <peter.maydell@linaro.org> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
This commit is contained in:
parent
bb16172c52
commit
a46667ea29
1 changed files with 2 additions and 0 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue