aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/vhost/tcm_vhost.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/drivers/vhost/tcm_vhost.c b/drivers/vhost/tcm_vhost.c
index 210d59e222fc..1bb0fb4950d1 100644
--- a/drivers/vhost/tcm_vhost.c
+++ b/drivers/vhost/tcm_vhost.c
@@ -578,6 +578,23 @@ static void tcm_vhost_submission_work(struct work_struct *work)
578 } 578 }
579} 579}
580 580
581static void vhost_scsi_send_bad_target(struct vhost_scsi *vs,
582 struct vhost_virtqueue *vq, int head, unsigned out)
583{
584 struct virtio_scsi_cmd_resp __user *resp;
585 struct virtio_scsi_cmd_resp rsp;
586 int ret;
587
588 memset(&rsp, 0, sizeof(rsp));
589 rsp.response = VIRTIO_SCSI_S_BAD_TARGET;
590 resp = vq->iov[out].iov_base;
591 ret = __copy_to_user(resp, &rsp, sizeof(rsp));
592 if (!ret)
593 vhost_add_used_and_signal(&vs->dev, vq, head, 0);
594 else
595 pr_err("Faulted on virtio_scsi_cmd_resp\n");
596}
597
581static void vhost_scsi_handle_vq(struct vhost_scsi *vs, 598static void vhost_scsi_handle_vq(struct vhost_scsi *vs,
582 struct vhost_virtqueue *vq) 599 struct vhost_virtqueue *vq)
583{ 600{
@@ -673,19 +690,7 @@ static void vhost_scsi_handle_vq(struct vhost_scsi *vs,
673 690
674 /* Target does not exist, fail the request */ 691 /* Target does not exist, fail the request */
675 if (unlikely(!tv_tpg)) { 692 if (unlikely(!tv_tpg)) {
676 struct virtio_scsi_cmd_resp __user *resp; 693 vhost_scsi_send_bad_target(vs, vq, head, out);
677 struct virtio_scsi_cmd_resp rsp;
678
679 memset(&rsp, 0, sizeof(rsp));
680 rsp.response = VIRTIO_SCSI_S_BAD_TARGET;
681 resp = vq->iov[out].iov_base;
682 ret = __copy_to_user(resp, &rsp, sizeof(rsp));
683 if (!ret)
684 vhost_add_used_and_signal(&vs->dev,
685 vq, head, 0);
686 else
687 pr_err("Faulted on virtio_scsi_cmd_resp\n");
688
689 continue; 694 continue;
690 } 695 }
691 696