From: Raphael Norwitz Date: Thu, 22 Aug 2019 18:34:25 +0000 (-0700) Subject: backends/vhost-user.c: prevent using uninitialized vqs X-Git-Tag: v4.2.0-rc0~97^2~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b8487a357855e78957d8c9bddbbcf58548e1aa51;p=thirdparty%2Fqemu.git backends/vhost-user.c: prevent using uninitialized vqs Similar rational to: e6cc11d64fc998c11a4dfcde8fda3fc33a74d844 For vhost scsi and vhost-user-scsi an issue was observed where, of the 3 virtqueues, seabios would only set cmd, leaving ctrl and event without a physical address. This can caused vhost_verify_ring_part_mapping to return ENOMEM, causing the following logs: qemu-system-x86_64: Unable to map available ring for ring 0 qemu-system-x86_64: Verify ring failure on region 0 The issue has already been fixed elsewhere, but it was noted that in backends/vhost-user.c, the vhost_user_backend_dev_init() function, which other vdevs use in their realize() to initialize their vqs, was not being properly zeroing out the queues. This commit ensures hardware modules using the vhost_user_backend_dev_init() API properly zero out their vqs on initialization. Suggested-by: Philippe Mathieu-Daude Signed-off-by: Raphael Norwitz Message-Id: <1566498865-55506-2-git-send-email-raphael.norwitz@nutanix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Stefan Hajnoczi --- diff --git a/backends/vhost-user.c b/backends/vhost-user.c index 0a13506c982..2bf3406525f 100644 --- a/backends/vhost-user.c +++ b/backends/vhost-user.c @@ -46,7 +46,7 @@ vhost_user_backend_dev_init(VhostUserBackend *b, VirtIODevice *vdev, b->vdev = vdev; b->dev.nvqs = nvqs; - b->dev.vqs = g_new(struct vhost_virtqueue, nvqs); + b->dev.vqs = g_new0(struct vhost_virtqueue, nvqs); ret = vhost_dev_init(&b->dev, &b->vhost_user, VHOST_BACKEND_TYPE_USER, 0); if (ret < 0) {