Skip to content

Commit

Permalink
virtiofsd: fv_create_listen_socket error path socket leak
Browse files Browse the repository at this point in the history
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>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
  • Loading branch information
dagrh committed Feb 10, 2020
1 parent 988717b commit 6fa2490
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tools/virtiofsd/fuse_virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -916,13 +916,15 @@ 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;
}
umask(old_umask);

if (listen(listen_sock, 1) == -1) {
fuse_log(FUSE_LOG_ERR, "vhost socket listen: %m\n");
close(listen_sock);
return -1;
}

Expand Down

0 comments on commit 6fa2490

Please sign in to comment.