From: Marc-André Lureau Date: Wed, 5 Jun 2019 14:58:26 +0000 (+0200) Subject: vhost-user: check unix_listen() return value X-Git-Tag: v4.1.0-rc0~50^2~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=24af03b946ce6889a435b2f3fc99daddde127874;p=thirdparty%2Fqemu.git vhost-user: check unix_listen() return value 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 Message-Id: <20190605145829.7674-3-marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- diff --git a/contrib/vhost-user-gpu/main.c b/contrib/vhost-user-gpu/main.c index 9614c9422c9..e0b6df5b4d8 100644 --- a/contrib/vhost-user-gpu/main.c +++ b/contrib/vhost-user-gpu/main.c @@ -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 { diff --git a/contrib/vhost-user-input/main.c b/contrib/vhost-user-input/main.c index 8d493f598e0..8b854117f5e 100644 --- a/contrib/vhost-user-input/main.c +++ b/contrib/vhost-user-input/main.c @@ -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 {