Commit 7f05630d authored by Xie Yongji's avatar Xie Yongji Committed by Michael S. Tsirkin

vhost-vdpa: Handle the failure of vdpa_reset()

The vdpa_reset() may fail now. This adds check to its return
value and fail the vhost_vdpa_open().
Signed-off-by: default avatarXie Yongji <xieyongji@bytedance.com>
Acked-by: default avatarJason Wang <jasowang@redhat.com>
Reviewed-by: default avatarStefano Garzarella <sgarzare@redhat.com>
Link: https://lore.kernel.org/r/20210831103634.33-7-xieyongji@bytedance.comSigned-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent 0686082d
...@@ -116,12 +116,13 @@ static void vhost_vdpa_unsetup_vq_irq(struct vhost_vdpa *v, u16 qid) ...@@ -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); 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; struct vdpa_device *vdpa = v->vdpa;
vdpa_reset(vdpa);
v->in_batch = 0; v->in_batch = 0;
return vdpa_reset(vdpa);
} }
static long vhost_vdpa_get_device_id(struct vhost_vdpa *v, u8 __user *argp) static long vhost_vdpa_get_device_id(struct vhost_vdpa *v, u8 __user *argp)
...@@ -865,7 +866,9 @@ static int vhost_vdpa_open(struct inode *inode, struct file *filep) ...@@ -865,7 +866,9 @@ static int vhost_vdpa_open(struct inode *inode, struct file *filep)
return -EBUSY; return -EBUSY;
nvqs = v->nvqs; nvqs = v->nvqs;
vhost_vdpa_reset(v); r = vhost_vdpa_reset(v);
if (r)
goto err;
vqs = kmalloc_array(nvqs, sizeof(*vqs), GFP_KERNEL); vqs = kmalloc_array(nvqs, sizeof(*vqs), GFP_KERNEL);
if (!vqs) { if (!vqs) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment