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

[Xen-devel] [PATCH 23/32] net: don't leak an fd after an error



From: Kaifeng Zhu <kaifeng.zhu@xxxxxxxxxx>

fd will be leaked if launch_script failed.

Signed-off-by: Kaifeng Zhu <kaifeng.zhu@xxxxxxxxxx>
Coverity-ID: 1055925
Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 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@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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