Skip to content

Commit

Permalink
vhost-vdpa: Handle the failure of vdpa_reset()
Browse files Browse the repository at this point in the history
The vdpa_reset() may fail now. This adds check to its return
value and fail the vhost_vdpa_open().

Signed-off-by: Xie Yongji <xieyongji@bytedance.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Link: https://lore.kernel.org/r/20210831103634.33-7-xieyongji@bytedance.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
  • Loading branch information
Xie Yongji authored and Michael S. Tsirkin committed Sep 6, 2021
1 parent 0686082 commit 7f05630
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions drivers/vhost/vdpa.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,13 @@ static void vhost_vdpa_unsetup_vq_irq(struct vhost_vdpa *v, u16 qid)
irq_bypass_unregister_producer(&vq->call_ctx.producer);
}

static void vhost_vdpa_reset(struct vhost_vdpa *v)
static int vhost_vdpa_reset(struct vhost_vdpa *v)
{
struct vdpa_device *vdpa = v->vdpa;

vdpa_reset(vdpa);
v->in_batch = 0;

return vdpa_reset(vdpa);
}

static long vhost_vdpa_get_device_id(struct vhost_vdpa *v, u8 __user *argp)
Expand Down Expand Up @@ -865,7 +866,9 @@ static int vhost_vdpa_open(struct inode *inode, struct file *filep)
return -EBUSY;

nvqs = v->nvqs;
vhost_vdpa_reset(v);
r = vhost_vdpa_reset(v);
if (r)
goto err;

vqs = kmalloc_array(nvqs, sizeof(*vqs), GFP_KERNEL);
if (!vqs) {
Expand Down

0 comments on commit 7f05630

Please sign in to comment.