diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2017-08-10 17:56:51 +0100 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2017-08-24 22:28:51 -0400 |
commit | 44ed8089e991a60d614abe0ee4b9057a28b364e4 (patch) | |
tree | f44db9181e333dcf02dd3a2c8b5e233337825326 | |
parent | 42d7c10f23786ed8521338ba6fd905a2459fa1e0 (diff) | |
download | op-kernel-dev-44ed8089e991a60d614abe0ee4b9057a28b364e4.zip op-kernel-dev-44ed8089e991a60d614abe0ee4b9057a28b364e4.tar.gz |
scsi: virtio: Reduce BUG if total_sg > virtqueue size to WARN.
If using indirect descriptors, you can make the total_sg as large as you
want. If not, BUG is too serious because the function later returns
-ENOSPC.
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r-- | drivers/virtio/virtio_ring.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 5e1b548..27cbc1e 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -296,7 +296,6 @@ static inline int virtqueue_add(struct virtqueue *_vq, } #endif - BUG_ON(total_sg > vq->vring.num); BUG_ON(total_sg == 0); head = vq->free_head; @@ -305,8 +304,10 @@ static inline int virtqueue_add(struct virtqueue *_vq, * buffers, then go indirect. FIXME: tune this threshold */ if (vq->indirect && total_sg > 1 && vq->vq.num_free) desc = alloc_indirect(_vq, total_sg, gfp); - else + else { desc = NULL; + WARN_ON_ONCE(total_sg > vq->vring.num && !vq->indirect); + } if (desc) { /* Use a single buffer which doesn't continue */ |