qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, patches@linaro.org
Subject: [Qemu-devel] [PATCH] gdbstub: Fix fd leak in gdbserver_open() error path
Date: Sat, 24 Dec 2011 23:37:24 +0000	[thread overview]
Message-ID: <1324769844-5991-1-git-send-email-peter.maydell@linaro.org> (raw)

Fix a leak of a file descriptor in error exit paths in
gdbserver_open().

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
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;
-- 
1.7.5.4

             reply	other threads:[~2011-12-24 23:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-24 23:37 Peter Maydell [this message]
2012-01-03 10:51 ` [Qemu-devel] [Qemu-trivial] [PATCH] gdbstub: Fix fd leak in gdbserver_open() error path Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1324769844-5991-1-git-send-email-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.org \
    --cc=patches@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).