qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vhost-user-scsi: avoid unlink(NULL) with fd passing
@ 2022-04-27 10:01 Stefan Hajnoczi
  2022-04-30  3:44 ` Raphael Norwitz
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Stefan Hajnoczi @ 2022-04-27 10:01 UTC (permalink / raw)
  To: qemu-devel; +Cc: Raphael Norwitz, Stefan Hajnoczi, Michael S. Tsirkin

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).

Fixes: Coverity CID 1488353
Fixes: 747421e949fc1eb3ba66b5fcccdb7ba051918241 ("Implements Backend Program conventions for vhost-user-scsi")
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 contrib/vhost-user-scsi/vhost-user-scsi.c | 4 +++-
 1 file changed, 3 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..08335d4b2b 100644
--- a/contrib/vhost-user-scsi/vhost-user-scsi.c
+++ b/contrib/vhost-user-scsi/vhost-user-scsi.c
@@ -433,7 +433,9 @@ out:
     if (vdev_scsi) {
         g_main_loop_unref(vdev_scsi->loop);
         g_free(vdev_scsi);
-        unlink(opt_socket_path);
+        if (opt_socket_path) {
+            unlink(opt_socket_path);
+        }
     }
     if (csock >= 0) {
         close(csock);
-- 
2.35.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-05-16 16:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-27 10:01 [PATCH] vhost-user-scsi: avoid unlink(NULL) with fd passing Stefan Hajnoczi
2022-04-30  3:44 ` Raphael Norwitz
2022-05-09 12:18 ` Philippe Mathieu-Daudé via
2022-05-12 15:57 ` Peter Maydell
2022-05-13 11:16   ` Michael S. Tsirkin
2022-05-16 15:57   ` Stefan Hajnoczi

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).