From patchwork Sat Dec 24 23:37:24 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 5963 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 A443B23E04 for ; Sat, 24 Dec 2011 23:37:28 +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 8F007A180F5 for ; Sat, 24 Dec 2011 23:37:28 +0000 (UTC) Received: by eaac11 with SMTP id c11so8103638eaa.11 for ; Sat, 24 Dec 2011 15:37:28 -0800 (PST) Received: by 10.205.138.136 with SMTP id is8mr5102821bkc.35.1324769848159; Sat, 24 Dec 2011 15:37:28 -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 ac16cs119676bkc; Sat, 24 Dec 2011 15:37:27 -0800 (PST) Received: by 10.216.137.155 with SMTP id y27mr16063967wei.53.1324769846288; Sat, 24 Dec 2011 15:37:26 -0800 (PST) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [81.2.115.146]) by mx.google.com with ESMTPS id r3si21101602wir.60.2011.12.24.15.37.26 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 24 Dec 2011 15:37:26 -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 1Reb9Y-0001Z4-3y; Sat, 24 Dec 2011 23:37:24 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, qemu-trivial@nongnu.org Subject: [PATCH] gdbstub: Fix fd leak in gdbserver_open() error path Date: Sat, 24 Dec 2011 23:37:24 +0000 Message-Id: <1324769844-5991-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 Fix a leak of a file descriptor in error exit paths in gdbserver_open(). Signed-off-by: Peter Maydell --- Of no great consequence, but it was in the pile of coverity complaints and it's a trivial fix. gdbstub.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index a5806ef..7d470b6 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -2762,11 +2762,13 @@ static int gdbserver_open(int port) ret = bind(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr)); if (ret < 0) { perror("bind"); + close(fd); return -1; } ret = listen(fd, 0); if (ret < 0) { perror("listen"); + close(fd); return -1; } return fd;