[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v2 86/86] vhost-user-scsi: avoid unlink(NULL) with fd passing
From: |
Michael S. Tsirkin |
Subject: |
[PULL v2 86/86] vhost-user-scsi: avoid unlink(NULL) with fd passing |
Date: |
Mon, 16 May 2022 16:56:02 -0400 |
From: Stefan Hajnoczi <stefanha@redhat.com>
Commit 747421e949fc1eb3ba66b5fcccdb7ba051918241 ("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: 747421e949fc1eb3ba66b5fcccdb7ba051918241 ("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>
---
contrib/vhost-user-scsi/vhost-user-scsi.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/contrib/vhost-user-scsi/vhost-user-scsi.c
b/contrib/vhost-user-scsi/vhost-user-scsi.c
index b2c0f98253..9ef61cf5a7 100644
--- a/contrib/vhost-user-scsi/vhost-user-scsi.c
+++ b/contrib/vhost-user-scsi/vhost-user-scsi.c
@@ -433,13 +433,16 @@ out:
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);
--
MST
- [PULL v2 76/86] hw/i386: Make pit a property of common x86 base machine type, (continued)
- [PULL v2 76/86] hw/i386: Make pit a property of common x86 base machine type, Michael S. Tsirkin, 2022/05/16
- [PULL v2 77/86] hw/i386: Make pic a property of common x86 base machine type, Michael S. Tsirkin, 2022/05/16
- [PULL v2 78/86] hw/i386/amd_iommu: Fix IOMMU event log encoding errors, Michael S. Tsirkin, 2022/05/16
- [PULL v2 79/86] virtio-net: setup vhost_dev and notifiers for cvq only when feature is negotiated, Michael S. Tsirkin, 2022/05/16
- [PULL v2 80/86] virtio-net: align ctrl_vq index for non-mq guest for vhost_vdpa, Michael S. Tsirkin, 2022/05/16
- [PULL v2 81/86] vhost-vdpa: fix improper cleanup in net_init_vhost_vdpa, Michael S. Tsirkin, 2022/05/16
- [PULL v2 83/86] vhost-vdpa: backend feature should set only once, Michael S. Tsirkin, 2022/05/16
- [PULL v2 82/86] vhost-net: fix improper cleanup in vhost_net_start, Michael S. Tsirkin, 2022/05/16
- [PULL v2 84/86] vhost-vdpa: change name and polarity for vhost_vdpa_one_time_request(), Michael S. Tsirkin, 2022/05/16
- [PULL v2 85/86] virtio-net: don't handle mq request in userspace handler for vhost-vdpa, Michael S. Tsirkin, 2022/05/16
- [PULL v2 86/86] vhost-user-scsi: avoid unlink(NULL) with fd passing,
Michael S. Tsirkin <=
- Re: [PULL v2 00/86] virtio,pc,pci: fixes,cleanups,features, Richard Henderson, 2022/05/16