aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/vhost/tcm_vhost.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/vhost/tcm_vhost.c b/drivers/vhost/tcm_vhost.c
index 1bb0fb4950d1..957a0b98a5d9 100644
--- a/drivers/vhost/tcm_vhost.c
+++ b/drivers/vhost/tcm_vhost.c
@@ -703,7 +703,7 @@ static void vhost_scsi_handle_vq(struct vhost_scsi *vs,
703 if (IS_ERR(tv_cmd)) { 703 if (IS_ERR(tv_cmd)) {
704 vq_err(vq, "vhost_scsi_allocate_cmd failed %ld\n", 704 vq_err(vq, "vhost_scsi_allocate_cmd failed %ld\n",
705 PTR_ERR(tv_cmd)); 705 PTR_ERR(tv_cmd));
706 break; 706 goto err_cmd;
707 } 707 }
708 pr_debug("Allocated tv_cmd: %p exp_data_len: %d, data_direction" 708 pr_debug("Allocated tv_cmd: %p exp_data_len: %d, data_direction"
709 ": %d\n", tv_cmd, exp_data_len, data_direction); 709 ": %d\n", tv_cmd, exp_data_len, data_direction);
@@ -729,7 +729,7 @@ static void vhost_scsi_handle_vq(struct vhost_scsi *vs,
729 " exceeds SCSI_MAX_VARLEN_CDB_SIZE: %d\n", 729 " exceeds SCSI_MAX_VARLEN_CDB_SIZE: %d\n",
730 scsi_command_size(tv_cmd->tvc_cdb), 730 scsi_command_size(tv_cmd->tvc_cdb),
731 TCM_VHOST_MAX_CDB_SIZE); 731 TCM_VHOST_MAX_CDB_SIZE);
732 goto err; 732 goto err_free;
733 } 733 }
734 tv_cmd->tvc_lun = ((v_req.lun[2] << 8) | v_req.lun[3]) & 0x3FFF; 734 tv_cmd->tvc_lun = ((v_req.lun[2] << 8) | v_req.lun[3]) & 0x3FFF;
735 735
@@ -742,7 +742,7 @@ static void vhost_scsi_handle_vq(struct vhost_scsi *vs,
742 data_direction == DMA_TO_DEVICE); 742 data_direction == DMA_TO_DEVICE);
743 if (unlikely(ret)) { 743 if (unlikely(ret)) {
744 vq_err(vq, "Failed to map iov to sgl\n"); 744 vq_err(vq, "Failed to map iov to sgl\n");
745 goto err; 745 goto err_free;
746 } 746 }
747 } 747 }
748 748
@@ -765,8 +765,10 @@ static void vhost_scsi_handle_vq(struct vhost_scsi *vs,
765 mutex_unlock(&vq->mutex); 765 mutex_unlock(&vq->mutex);
766 return; 766 return;
767 767
768err: 768err_free:
769 vhost_scsi_free_cmd(tv_cmd); 769 vhost_scsi_free_cmd(tv_cmd);
770err_cmd:
771 vhost_scsi_send_bad_target(vs, vq, head, out);
770 mutex_unlock(&vq->mutex); 772 mutex_unlock(&vq->mutex);
771} 773}
772 774