Skip to content

Commit

Permalink
vhost-user-scsi: avoid unlink(NULL) with fd passing
Browse files Browse the repository at this point in the history
Commit 747421e ("Implements Backend
Program conventions for vhost-user-scsi") introduced fd-passing support
as part of implementing the vhost-user backend program conventions.

When fd passing is used the UNIX domain socket path is NULL and we must
not call unlink(2).

The unlink(2) call is necessary when the listen socket, lsock, was
created successfully since that means the UNIX domain socket is visible
in the file system.

Fixes: Coverity CID 1488353
Fixes: 747421e ("Implements Backend Program conventions for vhost-user-scsi")
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20220516155701.1789638-1-stefanha@redhat.com>
Reviewed-by: Raphael Norwitz <raphael.norwitz@nutanix.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
  • Loading branch information
stefanhaRH authored and mstsirkin committed May 16, 2022
1 parent 2a7888c commit 6852c21
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion contrib/vhost-user-scsi/vhost-user-scsi.c
Expand Up @@ -433,13 +433,16 @@ int main(int argc, char **argv)
if (vdev_scsi) {
g_main_loop_unref(vdev_scsi->loop);
g_free(vdev_scsi);
unlink(opt_socket_path);
}
if (csock >= 0) {
close(csock);
}
if (lsock >= 0) {
close(lsock);

if (opt_socket_path) {
unlink(opt_socket_path);
}
}
g_free(opt_socket_path);
g_free(iscsi_uri);
Expand Down

0 comments on commit 6852c21

Please sign in to comment.