From: Andrew Cooper Subject: [PATCH 23/32] net: don't leak an fd after an error Date: Wed, 22 Apr 2015 16:08:00 +0100 Message-ID: <1429715289-4954-23-git-send-email-andrew.cooper3@citrix.com> References: <1429715235-4759-1-git-send-email-andrew.cooper3@citrix.com> <1429715289-4954-1-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1429715289-4954-1-git-send-email-andrew.cooper3@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Xen-devel List-Id: xen-devel@lists.xenproject.org From: Kaifeng Zhu fd will be leaked if launch_script failed. Signed-off-by: Kaifeng Zhu Coverity-ID: 1055925 Reviewed-by: Andrew Cooper --- 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