@@ -1069,12 +1069,17 @@ int iscsit_process_scsi_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
*/
if (!cmd->immediate_data) {
cmdsn_ret = iscsit_sequence_cmd(conn, cmd, hdr->cmdsn);
- if (cmdsn_ret == CMDSN_LOWER_THAN_EXP)
+ if (cmdsn_ret == CMDSN_LOWER_THAN_EXP) {
+ if (!cmd->sense_reason)
+ return 0;
+
+ target_put_sess_cmd(conn->sess->se_sess, &cmd->se_cmd);
return 0;
- else if (cmdsn_ret == CMDSN_ERROR_CANNOT_RECOVER)
+ } else if (cmdsn_ret == CMDSN_ERROR_CANNOT_RECOVER) {
return iscsit_add_reject_from_cmd(
ISCSI_REASON_PROTOCOL_ERROR,
1, 0, (unsigned char *)hdr, cmd);
+ }
}
iscsit_ack_from_expstatsn(conn, be32_to_cpu(hdr->exp_statsn));
@@ -1085,24 +1090,31 @@ int iscsit_process_scsi_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
if (!cmd->immediate_data) {
if (!cmd->sense_reason && cmd->unsolicited_data)
iscsit_set_unsoliticed_dataout(cmd);
+ if (!cmd->sense_reason)
+ return 0;
+ target_put_sess_cmd(conn->sess->se_sess, &cmd->se_cmd);
return 0;
}
/*
- * Early CHECK_CONDITIONs never make it to the transport processing
- * thread. They are processed in CmdSN order by
- * iscsit_check_received_cmdsn() below.
+ * Early CHECK_CONDITIONs with ImmediateData never make it to command
+ * execution. These exceptions are processed in CmdSN order using
+ * iscsit_check_received_cmdsn() in iscsit_get_immediate_data() below.
*/
- if (cmd->sense_reason)
+ if (cmd->sense_reason) {
+ target_put_sess_cmd(conn->sess->se_sess, &cmd->se_cmd);
return 1;
+ }
/*
* Call directly into transport_generic_new_cmd() to perform
* the backend memory allocation.
*/
cmd->sense_reason = transport_generic_new_cmd(&cmd->se_cmd);
- if (cmd->sense_reason)
+ if (cmd->sense_reason) {
+ target_put_sess_cmd(conn->sess->se_sess, &cmd->se_cmd);
return 1;
+ }
return 0;
}