All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert (git)" <dgilbert@redhat.com>
To: qemu-devel@nongnu.org, stefanha@redhat.com
Subject: [PATCH 2/4] virtiofsd: fv_create_listen_socket error path socket leak
Date: Tue,  4 Feb 2020 11:04:59 +0000	[thread overview]
Message-ID: <20200204110501.10731-3-dgilbert@redhat.com> (raw)
In-Reply-To: <20200204110501.10731-1-dgilbert@redhat.com>

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

If we fail when bringing up the socket we can leak the listen_fd;
in practice the daemon will exit so it's not really a problem.

Fixes: Coverity CID 1413121
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
 tools/virtiofsd/fuse_virtio.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/virtiofsd/fuse_virtio.c b/tools/virtiofsd/fuse_virtio.c
index 80a6e929df..dd1c605dbf 100644
--- a/tools/virtiofsd/fuse_virtio.c
+++ b/tools/virtiofsd/fuse_virtio.c
@@ -916,6 +916,7 @@ static int fv_create_listen_socket(struct fuse_session *se)
     old_umask = umask(0077);
     if (bind(listen_sock, (struct sockaddr *)&un, addr_len) == -1) {
         fuse_log(FUSE_LOG_ERR, "vhost socket bind: %m\n");
+        close(listen_sock);
         umask(old_umask);
         return -1;
     }
@@ -923,6 +924,7 @@ static int fv_create_listen_socket(struct fuse_session *se)
 
     if (listen(listen_sock, 1) == -1) {
         fuse_log(FUSE_LOG_ERR, "vhost socket listen: %m\n");
+        close(listen_sock);
         return -1;
     }
 
-- 
2.24.1



  parent reply	other threads:[~2020-02-04 11:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-04 11:04 [PATCH 0/4] virtiofsd coverity fixes Dr. David Alan Gilbert (git)
2020-02-04 11:04 ` [PATCH 1/4] virtiofsd: Remove fuse_req_getgroups Dr. David Alan Gilbert (git)
2020-02-04 11:59   ` Philippe Mathieu-Daudé
2020-02-04 11:04 ` Dr. David Alan Gilbert (git) [this message]
2020-02-04 12:00   ` [PATCH 2/4] virtiofsd: fv_create_listen_socket error path socket leak Philippe Mathieu-Daudé
2020-02-04 11:05 ` [PATCH 3/4] virtiofsd: load_capng missing unlock Dr. David Alan Gilbert (git)
2020-02-04 12:05   ` Philippe Mathieu-Daudé
2020-02-04 15:44     ` Dr. David Alan Gilbert
2020-02-04 16:06       ` Philippe Mathieu-Daudé
2020-02-04 11:05 ` [PATCH 4/4] virtiofsd: do_read missing NULL check Dr. David Alan Gilbert (git)
2020-02-04 12:03   ` Philippe Mathieu-Daudé
2020-02-05 14:31 ` [PATCH 0/4] virtiofsd coverity fixes 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=20200204110501.10731-3-dgilbert@redhat.com \
    --to=dgilbert@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.