vhost: fix virtqueues metadata allocation
authorMaxime Coquelin <maxime.coquelin@redhat.com>
Mon, 19 Oct 2020 17:34:09 +0000 (19:34 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 3 Nov 2020 22:24:26 +0000 (23:24 +0100)
commit8acd7c21335305426fbbc0a3aea2978734d0b2a8
tree19a82cb0a6cdb72e56b45f836e110c80bca5b8e1
parentd4fbb27459954bdbb9240d16b47bdfccf47c6e34
vhost: fix virtqueues metadata allocation

The Vhost-user backend implementation assumes there will be
no holes in the device's array of virtqueues metadata
pointers.

It can happen though, and would cause segmentation faults,
memory leaks or undefined behaviour.

This patch keep the assumption that there is no holes in this
array, and allocate all uninitialized virtqueues metadata up
to requested index.

Fixes: 160cbc815b41 ("vhost: remove a hack on queue allocation")
Cc: stable@dpdk.org
Suggested-by: Adrian Moreno <amorenoz@redhat.com>
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
lib/librte_vhost/vhost.c