Commit 4951cc90 authored by Rusty Russell's avatar Rusty Russell

virtio_balloon: don't crash if virtqueue is broken.

A bad implementation of virtio might cause us to mark the virtqueue
broken: we'll dev_err() in that case, and the device is useless, but
let's not BUG().
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent 5261b85e
...@@ -108,8 +108,7 @@ static void tell_host(struct virtio_balloon *vb, struct virtqueue *vq) ...@@ -108,8 +108,7 @@ static void tell_host(struct virtio_balloon *vb, struct virtqueue *vq)
sg_init_one(&sg, vb->pfns, sizeof(vb->pfns[0]) * vb->num_pfns); sg_init_one(&sg, vb->pfns, sizeof(vb->pfns[0]) * vb->num_pfns);
/* We should always be able to add one buffer to an empty queue. */ /* We should always be able to add one buffer to an empty queue. */
if (virtqueue_add_outbuf(vq, &sg, 1, vb, GFP_KERNEL) < 0) virtqueue_add_outbuf(vq, &sg, 1, vb, GFP_KERNEL);
BUG();
virtqueue_kick(vq); virtqueue_kick(vq);
/* When host has read buffer, this completes via balloon_ack */ /* When host has read buffer, this completes via balloon_ack */
...@@ -258,8 +257,7 @@ static void stats_handle_request(struct virtio_balloon *vb) ...@@ -258,8 +257,7 @@ static void stats_handle_request(struct virtio_balloon *vb)
if (!virtqueue_get_buf(vq, &len)) if (!virtqueue_get_buf(vq, &len))
return; return;
sg_init_one(&sg, vb->stats, sizeof(vb->stats)); sg_init_one(&sg, vb->stats, sizeof(vb->stats));
if (virtqueue_add_outbuf(vq, &sg, 1, vb, GFP_KERNEL) < 0) virtqueue_add_outbuf(vq, &sg, 1, vb, GFP_KERNEL);
BUG();
virtqueue_kick(vq); virtqueue_kick(vq);
} }
...@@ -344,7 +342,7 @@ static int init_vqs(struct virtio_balloon *vb) ...@@ -344,7 +342,7 @@ static int init_vqs(struct virtio_balloon *vb)
/* /*
* Prime this virtqueue with one buffer so the hypervisor can * Prime this virtqueue with one buffer so the hypervisor can
* use it to signal us later. * use it to signal us later (it can't be broken yet!).
*/ */
sg_init_one(&sg, vb->stats, sizeof vb->stats); sg_init_one(&sg, vb->stats, sizeof vb->stats);
if (virtqueue_add_outbuf(vb->stats_vq, &sg, 1, vb, GFP_KERNEL) if (virtqueue_add_outbuf(vb->stats_vq, &sg, 1, vb, GFP_KERNEL)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment