]> xenbits.xensource.com Git - people/andrewcoop/qemu-traditional.git/commitdiff
net: don't leak an fd after an error
authorKaifeng Zhu <kaifeng.zhu@citrix.com>
Fri, 7 Mar 2014 16:31:06 +0000 (16:31 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 16 Oct 2015 15:52:06 +0000 (16:52 +0100)
fd will be leaked if launch_script failed.

Signed-off-by: Kaifeng Zhu <kaifeng.zhu@citrix.com>
Coverity-ID: 1055925
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
net.c

diff --git a/net.c b/net.c
index 720027c3b26fe70f86ed5f377f251cdb7e165317..f3887a777f31e556cbbce1ec2e2b9ae53aaa21b5 100644 (file)
--- a/net.c
+++ b/net.c
@@ -1049,8 +1049,10 @@ static int net_tap_init(VLANState *vlan, const char *model,
     if (!setup_script || !strcmp(setup_script, "no"))
         setup_script = "";
     if (setup_script[0] != '\0') {
-       if (launch_script(setup_script, ifname, script_arg, fd))
+       if (launch_script(setup_script, ifname, script_arg, fd)) {
+           close(fd);
            return -1;
+       }
     }
     s = net_tap_fd_init(vlan, model, name, fd);
     if (!s)