From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39037) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XqPn5-0003Vk-Eg for qemu-devel@nongnu.org; Mon, 17 Nov 2014 12:08:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XqPn0-000678-1r for qemu-devel@nongnu.org; Mon, 17 Nov 2014 12:08:39 -0500 Received: from mail-wi0-x22e.google.com ([2a00:1450:400c:c05::22e]:38198) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XqPmz-00066y-SG for qemu-devel@nongnu.org; Mon, 17 Nov 2014 12:08:34 -0500 Received: by mail-wi0-f174.google.com with SMTP id h11so6368514wiw.1 for ; Mon, 17 Nov 2014 09:08:31 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Mon, 17 Nov 2014 18:08:10 +0100 Message-Id: <1416244099-7217-4-git-send-email-pbonzini@redhat.com> In-Reply-To: <1416244099-7217-1-git-send-email-pbonzini@redhat.com> References: <1416244099-7217-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 03/12] l2tpv3: fix fd leak List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gonglei From: Gonglei In this false branch, fd will leak when it is zero. Change the testing condition. Signed-off-by: Gonglei [Fix net_l2tpv3_cleanup as well. - Paolo] Signed-off-by: Paolo Bonzini --- net/l2tpv3.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/l2tpv3.c b/net/l2tpv3.c index 65db5ef..3b805a7 100644 --- a/net/l2tpv3.c +++ b/net/l2tpv3.c @@ -516,7 +516,7 @@ static void net_l2tpv3_cleanup(NetClientState *nc) qemu_purge_queued_packets(nc); l2tpv3_read_poll(s, false); l2tpv3_write_poll(s, false); - if (s->fd > 0) { + if (s->fd >= 0) { close(s->fd); } destroy_vector(s->msgvec, MAX_L2TPV3_MSGCNT, IOVSIZE); @@ -745,7 +745,7 @@ int net_init_l2tpv3(const NetClientOptions *opts, return 0; outerr: qemu_del_net_client(nc); - if (fd > 0) { + if (fd >= 0) { close(fd); } if (result) { -- 1.8.3.1