Skip to content

Commit 18a3c5f

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: "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
2 parents 90c911a + be286f8 commit 18a3c5f

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

drivers/vdpa/mlx5/core/mr.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,10 @@ static int map_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mr
278278
mr->log_size = log_entity_size;
279279
mr->nsg = nsg;
280280
mr->nent = dma_map_sg_attrs(dma, mr->sg_head.sgl, mr->nsg, DMA_BIDIRECTIONAL, 0);
281-
if (!mr->nent)
281+
if (!mr->nent) {
282+
err = -ENOMEM;
282283
goto err_map;
284+
}
283285

284286
err = create_direct_mr(mvdev, mr);
285287
if (err)

drivers/vhost/vdpa.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,9 +745,11 @@ static int vhost_vdpa_process_iotlb_msg(struct vhost_dev *dev,
745745
const struct vdpa_config_ops *ops = vdpa->config;
746746
int r = 0;
747747

748+
mutex_lock(&dev->mutex);
749+
748750
r = vhost_dev_check_owner(dev);
749751
if (r)
750-
return r;
752+
goto unlock;
751753

752754
switch (msg->type) {
753755
case VHOST_IOTLB_UPDATE:
@@ -768,6 +770,8 @@ static int vhost_vdpa_process_iotlb_msg(struct vhost_dev *dev,
768770
r = -EINVAL;
769771
break;
770772
}
773+
unlock:
774+
mutex_unlock(&dev->mutex);
771775

772776
return r;
773777
}

0 commit comments

Comments
 (0)