virtio_net: verify if queue is broken after virtqueue_get_buf()
authorHeinz Graalfs <graalfs@linux.vnet.ibm.com>
Mon, 28 Oct 2013 23:10:47 +0000 (09:40 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 29 Oct 2013 00:58:19 +0000 (11:28 +1030)
If a virtqueue_get_buf() call returns a NULL pointer a possibly endless while
loop should be avoided by checking for a broken virtqueue.

Signed-off-by: Heinz Graalfs <graalfs@linux.vnet.ibm.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
drivers/net/virtio_net.c

index ff208d2787d386f27acb2b2e8e1d3fd6ebd3152f..057ea133cd2be61f334200affd8567f7e9016567 100644 (file)
@@ -825,7 +825,8 @@ static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd,
        /* Spin for a response, the kick causes an ioport write, trapping
         * into the hypervisor, so the request should be handled immediately.
         */
-       while (!virtqueue_get_buf(vi->cvq, &tmp))
+       while (!virtqueue_get_buf(vi->cvq, &tmp) &&
+              !virtqueue_is_broken(vi->cvq))
                cpu_relax();
 
        return status == VIRTIO_NET_OK;