Commit 055f648c49d948de9452b0f1758869bbbd0097b8

Authored by Asias He
Committed by Nicholas Bellinger
1 parent 637ab21e28

tcm_vhost: Send bad target to guest when cmd fails

Send bad target to guest in case:
1) we can not allocate the cmd
2) fail to submit the cmd

Signed-off-by: Asias He <asias@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>

Showing 1 changed file with 6 additions and 4 deletions Side-by-side Diff

drivers/vhost/tcm_vhost.c
... ... @@ -703,7 +703,7 @@
703 703 if (IS_ERR(tv_cmd)) {
704 704 vq_err(vq, "vhost_scsi_allocate_cmd failed %ld\n",
705 705 PTR_ERR(tv_cmd));
706   - break;
  706 + goto err_cmd;
707 707 }
708 708 pr_debug("Allocated tv_cmd: %p exp_data_len: %d, data_direction"
709 709 ": %d\n", tv_cmd, exp_data_len, data_direction);
... ... @@ -729,7 +729,7 @@
729 729 " exceeds SCSI_MAX_VARLEN_CDB_SIZE: %d\n",
730 730 scsi_command_size(tv_cmd->tvc_cdb),
731 731 TCM_VHOST_MAX_CDB_SIZE);
732   - goto err;
  732 + goto err_free;
733 733 }
734 734 tv_cmd->tvc_lun = ((v_req.lun[2] << 8) | v_req.lun[3]) & 0x3FFF;
735 735  
... ... @@ -742,7 +742,7 @@
742 742 data_direction == DMA_TO_DEVICE);
743 743 if (unlikely(ret)) {
744 744 vq_err(vq, "Failed to map iov to sgl\n");
745   - goto err;
  745 + goto err_free;
746 746 }
747 747 }
748 748  
749 749  
... ... @@ -765,8 +765,10 @@
765 765 mutex_unlock(&vq->mutex);
766 766 return;
767 767  
768   -err:
  768 +err_free:
769 769 vhost_scsi_free_cmd(tv_cmd);
  770 +err_cmd:
  771 + vhost_scsi_send_bad_target(vs, vq, head, out);
770 772 mutex_unlock(&vq->mutex);
771 773 }
772 774