From patchwork Sat Dec 24 23:47:11 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 5964 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 959E423E04 for ; Sat, 24 Dec 2011 23:47:14 +0000 (UTC) Received: from mail-ey0-f180.google.com (mail-ey0-f180.google.com [209.85.215.180]) by fiordland.canonical.com (Postfix) with ESMTP id 81F6DA18106 for ; Sat, 24 Dec 2011 23:47:14 +0000 (UTC) Received: by eaac11 with SMTP id c11so8107054eaa.11 for ; Sat, 24 Dec 2011 15:47:14 -0800 (PST) Received: by 10.205.132.148 with SMTP id hu20mr2911091bkc.96.1324770434236; Sat, 24 Dec 2011 15:47:14 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.205.82.144 with SMTP id ac16cs119780bkc; Sat, 24 Dec 2011 15:47:14 -0800 (PST) Received: by 10.227.200.19 with SMTP id eu19mr9939705wbb.12.1324770432912; Sat, 24 Dec 2011 15:47:12 -0800 (PST) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [81.2.115.146]) by mx.google.com with ESMTPS id gn10si9633518wib.2.2011.12.24.15.47.12 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 24 Dec 2011 15:47:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) client-ip=81.2.115.146; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) smtp.mail=pm215@archaic.org.uk Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1RebJ1-0001aP-D0; Sat, 24 Dec 2011 23:47:11 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, qemu-trivial@nongnu.org Subject: [PATCH] net/socket.c: Fix fd leak in net_socket_listen_init() error paths Date: Sat, 24 Dec 2011 23:47:11 +0000 Message-Id: <1324770431-6074-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 Fix a leak of a file descriptor due to missing closesocket() calls in error paths in net_socket_listen_init(). Signed-off-by: Peter Maydell --- Coverity again... net/socket.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/net/socket.c b/net/socket.c index aaf9be4..c9d70d3 100644 --- a/net/socket.c +++ b/net/socket.c @@ -427,12 +427,14 @@ static int net_socket_listen_init(VLANState *vlan, if (ret < 0) { perror("bind"); g_free(s); + closesocket(fd); return -1; } ret = listen(fd, 0); if (ret < 0) { perror("listen"); g_free(s); + closesocket(fd); return -1; } s->vlan = vlan;