[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [qemu-xen-traditional stable-4.6] net: Fix memory/handle leaks in net_socket_listen_init()



commit 6b2a35d239b2462ac1bea07b74f4c88ec20e233a
Author:     Kaifeng Zhu <kaifeng.zhu@xxxxxxxxxx>
AuthorDate: Tue Apr 22 07:38:24 2014 +0100
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Fri Oct 16 16:52:06 2015 +0100

    net: Fix memory/handle leaks in net_socket_listen_init()
    
    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 files changed, 5 insertions(+), 0 deletions(-)

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;
--
generated by git-patchbot for /home/xen/git/qemu-xen-traditional.git#stable-4.6

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.