diff options
author | Heinz Graalfs <graalfs@linux.vnet.ibm.com> | 2013-10-29 00:10:47 +0100 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2013-10-29 01:58:19 +0100 |
commit | 047b9b94951dba2e93c65a582ae2bce25c960b86 (patch) | |
tree | 0164b14f46fb84a8508445611edbbcadc377096e /drivers/net/virtio_net.c | |
parent | virtio_console: verify if queue is broken after virtqueue_get_buf() (diff) | |
download | linux-047b9b94951dba2e93c65a582ae2bce25c960b86.tar.xz linux-047b9b94951dba2e93c65a582ae2bce25c960b86.zip |
virtio_net: verify if queue is broken after virtqueue_get_buf()
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>
Diffstat (limited to 'drivers/net/virtio_net.c')
-rw-r--r-- | drivers/net/virtio_net.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index ff208d2787d3..057ea133cd2b 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -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; |