[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 24/32] net: Fix memory/handle leaks in net_socket_listen_init()
From: Kaifeng Zhu <kaifeng.zhu@xxxxxxxxxx> fd and s could be leaked in case bind/listen failed. Signed-off-by: Kaifeng Zhu <kaifeng.zhu@xxxxxxxxxx> Coverity-IDs: 1055923 1055924 Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> --- net.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net.c b/net.c index f3887a7..33460d8 100644 --- a/net.c +++ b/net.c @@ -1460,6 +1460,7 @@ static int net_socket_listen_init(VLANState *vlan, fd = socket(PF_INET, SOCK_STREAM, 0); if (fd < 0) { perror("socket"); + qemu_free(s); return -1; } socket_set_nonblock(fd); @@ -1471,11 +1472,15 @@ static int net_socket_listen_init(VLANState *vlan, ret = bind(fd, (struct sockaddr *)&saddr, sizeof(saddr)); if (ret < 0) { perror("bind"); + closesocket(fd); + qemu_free(s); return -1; } ret = listen(fd, 0); if (ret < 0) { perror("listen"); + closesocket(fd); + qemu_free(s); return -1; } s->vlan = vlan; -- 1.7.10.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |