]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
vhost-user-input: check ioctl(EVIOCGNAME) return value
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Wed, 5 Jun 2019 14:58:28 +0000 (16:58 +0200)
committerMichael S. Tsirkin <mst@redhat.com>
Sun, 16 Jun 2019 20:16:52 +0000 (16:16 -0400)
This should fix coverity CID 1401704.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20190605145829.7674-5-marcandre.lureau@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
contrib/vhost-user-input/main.c

index 54f882602a4cbda6447d37560bdf53debd38ca74..8b4e7d25369fa05243786d5355fb772e415912de 100644 (file)
@@ -342,7 +342,11 @@ main(int argc, char *argv[])
 
     vi.config = g_array_new(false, false, sizeof(virtio_input_config));
     memset(&id, 0, sizeof(id));
-    ioctl(vi.evdevfd, EVIOCGNAME(sizeof(id.u.string) - 1), id.u.string);
+    if (ioctl(vi.evdevfd, EVIOCGNAME(sizeof(id.u.string) - 1),
+              id.u.string) < 0) {
+        g_printerr("Failed to get evdev name: %s\n", g_strerror(errno));
+        exit(EXIT_FAILURE);
+    }
     id.select = VIRTIO_INPUT_CFG_ID_NAME;
     id.size = strlen(id.u.string);
     g_array_append_val(vi.config, id);