Skip to content

Commit 7de41b1

Browse files
committed
Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
Pull virtio fixes from Michael Tsirkin: "Some bug fixes all over the place" * tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost: virtio_balloon: Adjust label in virtballoon_probe virtio-blk: improve virtqueue error to BLK_STS virtio-blk: fix hw_queue stopped on arbitrary error virtio_ring: Fix mem leak with vring_new_virtqueue()
2 parents 2c523b3 + 6ae4eda commit 7de41b1

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

drivers/block/virtio_blk.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,13 +245,20 @@ static blk_status_t virtio_queue_rq(struct blk_mq_hw_ctx *hctx,
245245
err = virtblk_add_req(vblk->vqs[qid].vq, vbr, vbr->sg, num);
246246
if (err) {
247247
virtqueue_kick(vblk->vqs[qid].vq);
248-
blk_mq_stop_hw_queue(hctx);
248+
/* Don't stop the queue if -ENOMEM: we may have failed to
249+
* bounce the buffer due to global resource outage.
250+
*/
251+
if (err == -ENOSPC)
252+
blk_mq_stop_hw_queue(hctx);
249253
spin_unlock_irqrestore(&vblk->vqs[qid].lock, flags);
250-
/* Out of mem doesn't actually happen, since we fall back
251-
* to direct descriptors */
252-
if (err == -ENOMEM || err == -ENOSPC)
254+
switch (err) {
255+
case -ENOSPC:
253256
return BLK_STS_DEV_RESOURCE;
254-
return BLK_STS_IOERR;
257+
case -ENOMEM:
258+
return BLK_STS_RESOURCE;
259+
default:
260+
return BLK_STS_IOERR;
261+
}
255262
}
256263

257264
if (bd->last && virtqueue_kick_prepare(vblk->vqs[qid].vq))

drivers/virtio/virtio_balloon.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -959,8 +959,8 @@ static int virtballoon_probe(struct virtio_device *vdev)
959959
iput(vb->vb_dev_info.inode);
960960
out_kern_unmount:
961961
kern_unmount(balloon_mnt);
962-
#endif
963962
out_del_vqs:
963+
#endif
964964
vdev->config->del_vqs(vdev);
965965
out_free_vb:
966966
kfree(vb);

drivers/virtio/virtio_ring.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2203,10 +2203,10 @@ void vring_del_virtqueue(struct virtqueue *_vq)
22032203
vq->split.queue_size_in_bytes,
22042204
vq->split.vring.desc,
22052205
vq->split.queue_dma_addr);
2206-
2207-
kfree(vq->split.desc_state);
22082206
}
22092207
}
2208+
if (!vq->packed_ring)
2209+
kfree(vq->split.desc_state);
22102210
list_del(&_vq->list);
22112211
kfree(vq);
22122212
}

0 commit comments

Comments
 (0)