From 8799d827aa4ab0882f90bbee7fa9aec4ee9529c5 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 1 Feb 2013 13:59:19 +0000 Subject: [PATCH] qla2x00t: Avoid that an SRR for a command without data triggers a kernel oops (merge r4747 from trunk) git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/2.2.x@4752 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- qla2x00t/qla2x00-target/qla2x00t.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/qla2x00t/qla2x00-target/qla2x00t.c b/qla2x00t/qla2x00-target/qla2x00t.c index 0379b0f15..04d6b75f5 100644 --- a/qla2x00t/qla2x00-target/qla2x00t.c +++ b/qla2x00t/qla2x00-target/qla2x00t.c @@ -4307,7 +4307,8 @@ static void q24_handle_srr(scsi_qla_host_t *ha, struct srr_ctio *sctio, break; case SRR_IU_DATA_IN: cmd->bufflen = scst_cmd_get_adjusted_resp_data_len(cmd->scst_cmd); - if (q2t_has_data(cmd)) { + if (q2t_has_data(cmd) && + (scst_cmd_get_data_direction(cmd->scst_cmd) & SCST_DATA_READ)) { uint32_t offset; int xmit_type; offset = le32_to_cpu(imm->imm.notify_entry24.srr_rel_offs); @@ -4320,16 +4321,18 @@ static void q24_handle_srr(scsi_qla_host_t *ha, struct srr_ctio *sctio, __q24_xmit_response(cmd, xmit_type); } else { PRINT_ERROR("qla2x00t(%ld): SRR for in data for cmd " - "without them (tag %d, SCSI status %d), " - "reject", ha->instance, cmd->tag, - scst_cmd_get_status(cmd->scst_cmd)); + "without them (tag %d, SCSI status %d, dir %d)," + " reject", ha->instance, cmd->tag, + scst_cmd_get_status(cmd->scst_cmd), + scst_cmd_get_data_direction(cmd->scst_cmd)); goto out_reject; } break; case SRR_IU_DATA_OUT: cmd->bufflen = scst_cmd_get_write_fields(cmd->scst_cmd, &cmd->sg, &cmd->sg_cnt); - if (q2t_has_data(cmd)) { + if (q2t_has_data(cmd) && + (scst_cmd_get_data_direction(cmd->scst_cmd) & SCST_DATA_WRITE)) { uint32_t offset; int xmit_type; offset = le32_to_cpu(imm->imm.notify_entry24.srr_rel_offs); @@ -4343,9 +4346,10 @@ static void q24_handle_srr(scsi_qla_host_t *ha, struct srr_ctio *sctio, __q2t_rdy_to_xfer(cmd); } else { PRINT_ERROR("qla2x00t(%ld): SRR for out data for cmd " - "without them (tag %d, SCSI status %d), " - "reject", ha->instance, cmd->tag, - scst_cmd_get_status(cmd->scst_cmd)); + "without them (tag %d, SCSI status %d, dir %d)," + " reject", ha->instance, cmd->tag, + scst_cmd_get_status(cmd->scst_cmd), + scst_cmd_get_data_direction(cmd->scst_cmd)); goto out_reject; } break;