Skip to content

Commit 1394103

Browse files
YongjiXiemstsirkin
authored andcommitted
vduse: Disallow injecting interrupt before DRIVER_OK is set
The interrupt callback should not be triggered before DRIVER_OK is set. Otherwise, it might break the virtio device driver. So let's add a check to avoid the unexpected behavior. Fixes: c8a6153 ("vduse: Introduce VDUSE - vDPA Device in Userspace") Signed-off-by: Xie Yongji <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent 6422251 commit 1394103

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

drivers/vdpa/vdpa_user/vduse_dev.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,10 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd,
966966
break;
967967
}
968968
case VDUSE_DEV_INJECT_CONFIG_IRQ:
969+
ret = -EINVAL;
970+
if (!(dev->status & VIRTIO_CONFIG_S_DRIVER_OK))
971+
break;
972+
969973
ret = 0;
970974
queue_work(vduse_irq_wq, &dev->inject);
971975
break;
@@ -1045,6 +1049,10 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd,
10451049
case VDUSE_VQ_INJECT_IRQ: {
10461050
u32 index;
10471051

1052+
ret = -EINVAL;
1053+
if (!(dev->status & VIRTIO_CONFIG_S_DRIVER_OK))
1054+
break;
1055+
10481056
ret = -EFAULT;
10491057
if (get_user(index, (u32 __user *)argp))
10501058
break;

0 commit comments

Comments
 (0)