From: Kaifeng Zhu Date: Fri, 7 Mar 2014 16:31:06 +0000 (+0000) Subject: net: don't leak an fd after an error X-Git-Tag: xen-4.6.1~13 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=b1b6594ba444ce418fd183bedeed179ace42dab1;p=qemu-xen-traditional.git net: don't leak an fd after an error fd will be leaked if launch_script failed. Signed-off-by: Kaifeng Zhu Coverity-ID: 1055925 Reviewed-by: Andrew Cooper --- diff --git a/net.c b/net.c index 720027c3..f3887a77 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)