virtio: fixes

Some bug fixes all over the place.
 
 Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
 -----BEGIN PGP SIGNATURE-----
 
 iQFDBAABCAAtFiEEXQn9CHHI+FuUyooNKB8NuNKNVGkFAl5kvHgPHG1zdEByZWRo
 YXQuY29tAAoJECgfDbjSjVRpMHYH/i3YXD+xcmA6t4hVQp7w+w2Lp0HK/zGCY+nh
 CZEcH0DThaNfUSZeCANb3BndHp2e7rcKydNdGDQN3q1lC6jmRq+O98ZoR7TDlTLt
 jIKlGgR+YyCGBkl5HpEEaqUI4YbtgdtZtYOilwPcYQCbTz0SkRI8avcIQbHplttW
 NsxuvohrVyfCCb+VWVdnXy94A4YHI5tq4Ups/I/NkloxXnKcJ99GrlHWWWKa6oJG
 HEi67oqVZO4MImPBkA1zekf4mbThbI+FL5gETUvkr6v4cSYa69mqyIt27Ft/e87M
 5EJp7GnH0HasZCHVAeGs8Qs09zX+AqPO2aMnoPhKm/mUhWu6gNo=
 =34RW
 -----END PGP SIGNATURE-----

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()
This commit is contained in:
Linus Torvalds 2020-03-09 16:02:32 -07:00
commit 7de41b120b
3 changed files with 15 additions and 8 deletions

View file

@ -245,13 +245,20 @@ static blk_status_t virtio_queue_rq(struct blk_mq_hw_ctx *hctx,
err = virtblk_add_req(vblk->vqs[qid].vq, vbr, vbr->sg, num);
if (err) {
virtqueue_kick(vblk->vqs[qid].vq);
blk_mq_stop_hw_queue(hctx);
/* Don't stop the queue if -ENOMEM: we may have failed to
* bounce the buffer due to global resource outage.
*/
if (err == -ENOSPC)
blk_mq_stop_hw_queue(hctx);
spin_unlock_irqrestore(&vblk->vqs[qid].lock, flags);
/* Out of mem doesn't actually happen, since we fall back
* to direct descriptors */
if (err == -ENOMEM || err == -ENOSPC)
switch (err) {
case -ENOSPC:
return BLK_STS_DEV_RESOURCE;
return BLK_STS_IOERR;
case -ENOMEM:
return BLK_STS_RESOURCE;
default:
return BLK_STS_IOERR;
}
}
if (bd->last && virtqueue_kick_prepare(vblk->vqs[qid].vq))

View file

@ -959,8 +959,8 @@ static int virtballoon_probe(struct virtio_device *vdev)
iput(vb->vb_dev_info.inode);
out_kern_unmount:
kern_unmount(balloon_mnt);
#endif
out_del_vqs:
#endif
vdev->config->del_vqs(vdev);
out_free_vb:
kfree(vb);

View file

@ -2203,10 +2203,10 @@ void vring_del_virtqueue(struct virtqueue *_vq)
vq->split.queue_size_in_bytes,
vq->split.vring.desc,
vq->split.queue_dma_addr);
kfree(vq->split.desc_state);
}
}
if (!vq->packed_ring)
kfree(vq->split.desc_state);
list_del(&_vq->list);
kfree(vq);
}