net/socket.c : fix memory leak

Signed-off-by: Li Zhi Hui <zhihuili@linux.vnet.ibm.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
This commit is contained in:
Zhi Hui Li 2011-11-24 16:23:00 +08:00 committed by Stefan Hajnoczi
parent b48e361194
commit c7ee8f683d
1 changed files with 3 additions and 0 deletions

View File

@ -409,6 +409,7 @@ static int net_socket_listen_init(VLANState *vlan,
fd = qemu_socket(PF_INET, SOCK_STREAM, 0);
if (fd < 0) {
perror("socket");
g_free(s);
return -1;
}
socket_set_nonblock(fd);
@ -420,11 +421,13 @@ static int net_socket_listen_init(VLANState *vlan,
ret = bind(fd, (struct sockaddr *)&saddr, sizeof(saddr));
if (ret < 0) {
perror("bind");
g_free(s);
return -1;
}
ret = listen(fd, 0);
if (ret < 0) {
perror("listen");
g_free(s);
return -1;
}
s->vlan = vlan;