summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Easi <aeasi@marvell.com>2019-08-23 02:52:33 -0700
committerMartin K. Petersen <martin.petersen@oracle.com>2019-08-29 18:44:22 -0400
commit47aeee5549cf9326656a8f9190960dfd35c101e2 (patch)
tree42db22cd688d96116c3eb299efd89c74efa037df
parent4909e153e608360702ad34f76f72190bfaec3d9d (diff)
scsi: qedf: Fix crash during sg_reset
Driver was attempting to print cdb[0], which is not set for resets coming from SCSI ioctls. Check for cmd_len before accessing cmnd. Crash info: [84790.864747] BUG: unable to handle kernel NULL pointer dereference at (null) [84790.864783] IP: qedf_initiate_tmf+0x7a/0x6e0 [qedf] [84790.865204] Call Trace: [84790.865246] scsi_try_target_reset+0x2b/0x90 [scsi_mod] [84790.865266] scsi_ioctl_reset+0x20f/0x2a0 [scsi_mod] [84790.865284] scsi_ioctl+0x131/0x3a0 [scsi_mod] Signed-off-by: Arun Easi <aeasi@marvell.com> Signed-off-by: Saurav Kashyap <skashyap@marvell.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r--drivers/scsi/qedf/qedf_io.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/scsi/qedf/qedf_io.c b/drivers/scsi/qedf/qedf_io.c
index 5b428922b83e..7377a534ff0e 100644
--- a/drivers/scsi/qedf/qedf_io.c
+++ b/drivers/scsi/qedf/qedf_io.c
@@ -2403,8 +2403,8 @@ int qedf_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags)
QEDF_ERR(NULL,
"tm_flags 0x%x sc_cmd %p op = 0x%02x target_id = 0x%x lun=%d\n",
- tm_flags, sc_cmd, sc_cmd->cmnd[0], rport->scsi_target_id,
- (int)sc_cmd->device->lun);
+ tm_flags, sc_cmd, sc_cmd->cmd_len ? sc_cmd->cmnd[0] : 0xff,
+ rport->scsi_target_id, (int)sc_cmd->device->lun);
if (!rdata || !kref_get_unless_zero(&rdata->kref)) {
QEDF_ERR(NULL, "stale rport\n");