Skip to contentSkip to conversation

virtio: ignore corrupted virtqueues rather than spinning.

PATCH New Rusty Russell 1 participant 1 message Apr 24, 2008 virtio core

lore
Share & tools
lore
#0 lore raw

PATCH 1/6 virtio: ignore corrupted virtqueues rather than spinning.

A corrupt virtqueue (caused by the other end screwing up) can have strange results such as a driver spinning: just bail when we try to get a buffer from a known-broken queue.

---
 drivers/virtio/virtio_ring.c |    5 +++++
 1 file changed, 5 insertions(+)
drivers/virtio/virtio_ring.c +5 -0
diff -r cbd83e592664 drivers/virtio/virtio_ring.c
@@ -184,6 +184,11 @@ static void *vring_get_buf(struct virtqu
 
 	START_USE(vq);
 
+	if (unlikely(vq->broken)) {
+		END_USE(vq);
+		return NULL;
+	}
+
 	if (!more_used(vq)) {
 		pr_debug("No more buffers in queue\n");
 		END_USE(vq);