vhost-user: check unix_listen() return value
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Wed, 5 Jun 2019 14:58:26 +0000 (16:58 +0200)
committerMichael S. Tsirkin <mst@redhat.com>
Sun, 16 Jun 2019 20:16:52 +0000 (16:16 -0400)
This check shouldn't be necessary, since &error_fatal is given as
argument and will exit() on failure. However, this change should
silence coverity CID 1401761 & 1401705.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20190605145829.7674-3-marcandre.lureau@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
contrib/vhost-user-gpu/main.c
contrib/vhost-user-input/main.c

index 9614c9422c9f65cbdea9643eb52c52578b356b10..e0b6df5b4d85bb6fdf325a0b4f1743f35c0c2497 100644 (file)
@@ -1160,6 +1160,10 @@ main(int argc, char *argv[])
 
     if (opt_socket_path) {
         int lsock = unix_listen(opt_socket_path, &error_fatal);
+        if (lsock < 0) {
+            g_printerr("Failed to listen on %s.\n", opt_socket_path);
+            exit(EXIT_FAILURE);
+        }
         fd = accept(lsock, NULL, NULL);
         close(lsock);
     } else {
index 8d493f598e021450a0d104d082ffb4ff975dd326..8b854117f5e3aaf14c9bc1707f7a8a4f3db7edd7 100644 (file)
@@ -367,6 +367,10 @@ main(int argc, char *argv[])
 
     if (opt_socket_path) {
         int lsock = unix_listen(opt_socket_path, &error_fatal);
+        if (lsock < 0) {
+            g_printerr("Failed to listen on %s.\n", opt_socket_path);
+            exit(EXIT_FAILURE);
+        }
         fd = accept(lsock, NULL, NULL);
         close(lsock);
     } else {