On Mon, 16 Jul 2018 18:37:42 +0100 "Dr. David Alan Gilbert (git)" <dgilb...@redhat.com> wrote:
> From: "Dr. David Alan Gilbert" <dgilb...@redhat.com> > > Rather than asserting, check values and return NULL > on failure. > > Signed-off-by: Dr. David Alan Gilbert <dgilb...@redhat.com> > --- > hw/scsi/virtio-scsi.c | 15 ++++++++++++--- > 1 file changed, 12 insertions(+), 3 deletions(-) > > diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c > index 6301af76ad..3441bfe6d7 100644 > --- a/hw/scsi/virtio-scsi.c > +++ b/hw/scsi/virtio-scsi.c > @@ -204,7 +204,11 @@ static void *virtio_scsi_load_request(QEMUFile *f, > SCSIRequest *sreq) > uint32_t n; > > qemu_get_be32s(f, &n); > - assert(n < vs->conf.num_queues); > + if (n >= vs->conf.num_queues) { > + error_report("%s: Bad queue number (%d vs %d)", > + __func__, n, vs->conf.num_queues); Hm... "(%d, num_queues %d)" might be a bit clearer? > + return NULL; > + } > req = qemu_get_virtqueue_element(vdev, f, > sizeof(VirtIOSCSIReq) + vs->cdb_size); > if (!req) { Still, Reviewed-by: Cornelia Huck <coh...@redhat.com>