virtio: last minute fixes

Very late in the cycle but both risky if left unfixed and more or less
 obvious..
 
 Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
 -----BEGIN PGP SIGNATURE-----
 
 iQFDBAABCAAtFiEEXQn9CHHI+FuUyooNKB8NuNKNVGkFAmCB9k0PHG1zdEByZWRo
 YXQuY29tAAoJECgfDbjSjVRpWsAIALdmVH9jkmih5R4HUVHPWzzTQKdwpUk0kNoi
 AE80GWEDbKKNmFv2L23oX2jgfyVlNe5kGIw/kTc+DUngNTxAFfzRcXM42ix76bXP
 GthLXGu5bRnAw1r59fNRXesa+dphpfT45n4pnLRxZCC/ahtT0GZiK9fqMDzy+wEc
 mluKtL7hKxp2LPj2GupZ9WBCDKmcVwDKnmc2U87F4zDb12LWZaEU8zxUvJv5OyGS
 fXbQ0bEa8Z6iOHl9CAiwcc+5Iv67zTA/dm5trYPFDl44K9tIBB+aBzDH8gzclRrg
 fKQuClkYyst3j8Uvq0T8rSW5t/6z37X7D3q8sgNJDh4FY1dAd6M=
 =9K6w
 -----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:
 "Very late in the cycle but both risky if left unfixed and more or less
  obvious.."

* tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost:
  vdpa/mlx5: Set err = -ENOMEM in case dma_map_sg_attrs fails
  vhost-vdpa: protect concurrent access to vhost device iotlb
This commit is contained in:
Linus Torvalds 2021-04-22 16:28:18 -07:00
commit 18a3c5f7ab
2 changed files with 8 additions and 2 deletions

View File

@ -278,8 +278,10 @@ static int map_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mr
mr->log_size = log_entity_size;
mr->nsg = nsg;
mr->nent = dma_map_sg_attrs(dma, mr->sg_head.sgl, mr->nsg, DMA_BIDIRECTIONAL, 0);
if (!mr->nent)
if (!mr->nent) {
err = -ENOMEM;
goto err_map;
}
err = create_direct_mr(mvdev, mr);
if (err)

View File

@ -745,9 +745,11 @@ static int vhost_vdpa_process_iotlb_msg(struct vhost_dev *dev,
const struct vdpa_config_ops *ops = vdpa->config;
int r = 0;
mutex_lock(&dev->mutex);
r = vhost_dev_check_owner(dev);
if (r)
return r;
goto unlock;
switch (msg->type) {
case VHOST_IOTLB_UPDATE:
@ -768,6 +770,8 @@ static int vhost_vdpa_process_iotlb_msg(struct vhost_dev *dev,
r = -EINVAL;
break;
}
unlock:
mutex_unlock(&dev->mutex);
return r;
}