Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+3 -5
+3 -5
drivers/virtio/virtio_balloon.c
··· 108 108 sg_init_one(&sg, vb->pfns, sizeof(vb->pfns[0]) * vb->num_pfns); 109 109 110 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) 112 - BUG(); 111 + virtqueue_add_outbuf(vq, &sg, 1, vb, GFP_KERNEL); 113 112 virtqueue_kick(vq); 114 113 115 114 /* When host has read buffer, this completes via balloon_ack */ ··· 257 258 if (!virtqueue_get_buf(vq, &len)) 258 259 return; 259 260 sg_init_one(&sg, vb->stats, sizeof(vb->stats)); 260 - if (virtqueue_add_outbuf(vq, &sg, 1, vb, GFP_KERNEL) < 0) 261 - BUG(); 261 + virtqueue_add_outbuf(vq, &sg, 1, vb, GFP_KERNEL); 262 262 virtqueue_kick(vq); 263 263 } 264 264 ··· 342 344 343 345 /* 344 346 * Prime this virtqueue with one buffer so the hypervisor can 345 - * use it to signal us later. 347 + * use it to signal us later (it can't be broken yet!). 346 348 */ 347 349 sg_init_one(&sg, vb->stats, sizeof vb->stats); 348 350 if (virtqueue_add_outbuf(vb->stats_vq, &sg, 1, vb, GFP_KERNEL)