tests: vhost-user-test: initialize 'fd' in chr_read
authorLi Qiang <liq3ea@163.com>
Sat, 15 Dec 2018 12:03:51 +0000 (04:03 -0800)
committerMichael S. Tsirkin <mst@redhat.com>
Tue, 15 Jan 2019 00:31:04 +0000 (19:31 -0500)
Currently when processing VHOST_USER_SET_VRING_CALL
if 'qemu_chr_fe_get_msgfds' get no fd, the 'fd' will
be a stack uninitialized value.

Signed-off-by: Li Qiang <liq3ea@163.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
tests/vhost-user-test.c

index 54982f68e7321e7360c204495280e79fb6365104..84e50d84e71caf808e0af3786649454e8f3d7802 100644 (file)
@@ -309,7 +309,7 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)
     CharBackend *chr = &s->chr;
     VhostUserMsg msg;
     uint8_t *p = (uint8_t *) &msg;
-    int fd;
+    int fd = -1;
 
     if (s->test_fail) {
         qemu_chr_fe_disconnect(chr);