Re: [PATCH] hw/virtio/vhost: check nvqs at dev_start

2023-10-02 Thread Albert Esteve
Ah I see, I wanted to move the fail check as early as possible, and went a bit too far ahead, before initialisation. But is ok, it needs its own value either way. What about returning -EFAULT? Or maybe -EINVAL? I think they would fit for this error. And then I can use `VHOST_OPS_DEBUG` to make it

Re: [PATCH] hw/virtio/vhost: check nvqs at dev_start

2023-10-02 Thread Michael S. Tsirkin
On Fri, Sep 01, 2023 at 02:23:23PM +0200, Albert Esteve wrote: > While this is not expected to happen, it could still > be that a vhost_dev did not set its nvqs member. > > Since `vhost_dev_start` access the device's vqs array > later without checking its size, it would cause a > Segmentation faul

[PATCH] hw/virtio/vhost: check nvqs at dev_start

2023-09-01 Thread Albert Esteve
While this is not expected to happen, it could still be that a vhost_dev did not set its nvqs member. Since `vhost_dev_start` access the device's vqs array later without checking its size, it would cause a Segmentation fault when nvqs is 0. To avoid this `rare` case and made the code safer, add a