On Mon, 16 Jul 2018 18:37:41 +0100 "Dr. David Alan Gilbert (git)" <dgilb...@redhat.com> wrote:
> From: "Dr. David Alan Gilbert" <dgilb...@redhat.com> > > Check calls to qemu_get_virtqueue_element for NULL and pass > up the chain. > > Signed-off-by: Dr. David Alan Gilbert <dgilb...@redhat.com> > --- > hw/block/virtio-blk.c | 4 ++++ > hw/char/virtio-serial-bus.c | 4 ++++ > hw/scsi/virtio-scsi.c | 4 ++++ > 3 files changed, 12 insertions(+) > > diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c > index 50b5c869e3..324c6b2b27 100644 > --- a/hw/block/virtio-blk.c > +++ b/hw/block/virtio-blk.c > @@ -888,6 +888,10 @@ static int virtio_blk_load_device(VirtIODevice *vdev, > QEMUFile *f, > } > > req = qemu_get_virtqueue_element(vdev, f, sizeof(VirtIOBlockReq)); > + if (!req) { > + error_report("%s: Bad vq element %u", __func__, vq_idx); Minor nit: vq_idx is the virtqueue index, and this message makes it look like it is the 'bad vq element'... either add 'vq index', or drop it completely from the error message? > + return -EINVAL; > + } > virtio_blk_init_request(s, virtio_get_queue(vdev, vq_idx), req); > req->next = s->rq; > s->rq = req; Anyway, Reviewed-by: Cornelia Huck <coh...@redhat.com>