From: Kaifeng Zhu <kaifeng....@citrix.com>

fd will be leaked if launch_script failed.

Signed-off-by: Kaifeng Zhu <kaifeng....@citrix.com>
Coverity-ID: 1055925
Reviewed-by: Andrew Cooper <andrew.coop...@citrix.com>
---
 net.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net.c b/net.c
index 720027c..f3887a7 100644
--- 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)
-- 
1.7.10.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

Reply via email to