aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/virtio
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2014-03-12 20:53:40 -0400
committerRusty Russell <rusty@rustcorp.com.au>2014-03-12 20:57:56 -0400
commit4951cc9083147015338f61a187e072daf02dfd4e (patch)
tree600821ce6f9733fec02bac2b8d188f8a9d11a7b0 /drivers/virtio
parent5261b85e586afe6ebe54e16e0a8acc32fc6d4902 (diff)
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: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/virtio')
-rw-r--r--drivers/virtio/virtio_balloon.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
index 36e7859a31aa..25ebe8eecdb7 100644
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -108,8 +108,7 @@ static void tell_host(struct virtio_balloon *vb, struct virtqueue *vq)
108 sg_init_one(&sg, vb->pfns, sizeof(vb->pfns[0]) * vb->num_pfns); 108 sg_init_one(&sg, vb->pfns, sizeof(vb->pfns[0]) * vb->num_pfns);
109 109
110 /* We should always be able to add one buffer to an empty queue. */ 110 /* We should always be able to add one buffer to an empty queue. */
111 if (virtqueue_add_outbuf(vq, &sg, 1, vb, GFP_KERNEL) < 0) 111 virtqueue_add_outbuf(vq, &sg, 1, vb, GFP_KERNEL);
112 BUG();
113 virtqueue_kick(vq); 112 virtqueue_kick(vq);
114 113
115 /* When host has read buffer, this completes via balloon_ack */ 114 /* When host has read buffer, this completes via balloon_ack */
@@ -258,8 +257,7 @@ static void stats_handle_request(struct virtio_balloon *vb)
258 if (!virtqueue_get_buf(vq, &len)) 257 if (!virtqueue_get_buf(vq, &len))
259 return; 258 return;
260 sg_init_one(&sg, vb->stats, sizeof(vb->stats)); 259 sg_init_one(&sg, vb->stats, sizeof(vb->stats));
261 if (virtqueue_add_outbuf(vq, &sg, 1, vb, GFP_KERNEL) < 0) 260 virtqueue_add_outbuf(vq, &sg, 1, vb, GFP_KERNEL);
262 BUG();
263 virtqueue_kick(vq); 261 virtqueue_kick(vq);
264} 262}
265 263
@@ -344,7 +342,7 @@ static int init_vqs(struct virtio_balloon *vb)
344 342
345 /* 343 /*
346 * Prime this virtqueue with one buffer so the hypervisor can 344 * Prime this virtqueue with one buffer so the hypervisor can
347 * use it to signal us later. 345 * use it to signal us later (it can't be broken yet!).
348 */ 346 */
349 sg_init_one(&sg, vb->stats, sizeof vb->stats); 347 sg_init_one(&sg, vb->stats, sizeof vb->stats);
350 if (virtqueue_add_outbuf(vb->stats_vq, &sg, 1, vb, GFP_KERNEL) 348 if (virtqueue_add_outbuf(vb->stats_vq, &sg, 1, vb, GFP_KERNEL)