vhost-user-input: check ioctl(EVIOCGNAME) return value

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>
This commit is contained in:
Marc-André Lureau 2019-06-05 16:58:28 +02:00 committed by Michael S. Tsirkin
parent f55411cf14
commit be32fd9ee1
1 changed files with 5 additions and 1 deletions

View 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);