Heinz Graalfs <graalfs@xxxxxxxxxxxxxxxxxx> writes: > If virtqueue_get_buf() returned with a NULL pointer avoid a possibly > endless loop by checking for a broken virtqueue. > > Signed-off-by: Heinz Graalfs <graalfs@xxxxxxxxxxxxxxxxxx> > --- > drivers/scsi/virtio_scsi.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c > index 74b88ef..45bcdb5 100644 > --- a/drivers/scsi/virtio_scsi.c > +++ b/drivers/scsi/virtio_scsi.c > @@ -224,7 +224,8 @@ static void virtscsi_vq_done(struct virtio_scsi *vscsi, > virtqueue_disable_cb(vq); > while ((buf = virtqueue_get_buf(vq, &len)) != NULL) > fn(vscsi, buf); > - } while (!virtqueue_enable_cb(vq)); > + } while (unlikely(!virtqueue_is_broken(vq)) && > + !virtqueue_enable_cb(vq)); > spin_unlock_irqrestore(&virtscsi_vq->vq_lock, flags); unlikely(!virtqueue_is_broken(vq))? I didn't apply this one. I'd prefer: spin_lock_irqsave(&virtscsi_vq->vq_lock, flags); do { virtqueue_disable_cb(vq); while ((buf = virtqueue_get_buf(vq, &len)) != NULL) fn(vscsi, buf); if (unlikely(virtqueue_is_broken(vq))) break; } while (!virtqueue_enable_cb(vq)); spin_unlock_irqrestore(&virtscsi_vq->vq_lock, flags); Thanks, Rusty. _______________________________________________ Virtualization mailing list Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx https://lists.linuxfoundation.org/mailman/listinfo/virtualization