From 6fab2f3f6064ad0a712c6d9213b9151bcc87c3d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Wed, 27 Jul 2016 01:15:10 +0400 Subject: [PATCH] vhost-user: check qemu_chr_fe_set_msgfds() return value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Check qemu_chr_fe_set_msgfds() for errors, to make sure the message to be sent is correct. Signed-off-by: Marc-André Lureau Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-user.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index f01b92f51271..5dae49615c2d 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -187,7 +187,9 @@ static int vhost_user_write(struct vhost_dev *dev, VhostUserMsg *msg, return 0; } - qemu_chr_fe_set_msgfds(chr, fds, fd_num); + if (qemu_chr_fe_set_msgfds(chr, fds, fd_num) < 0) { + return -1; + } return qemu_chr_fe_write_all(chr, (const uint8_t *) msg, size) == size ? 0 : -1;