diff options
author | Don Brace <don.brace@microsemi.com> | 2016-09-09 16:30:42 -0500 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2016-09-14 14:21:54 -0400 |
commit | 45e596cd6ead1c4ada74b03067595d7f4502fa6a (patch) | |
tree | a8169773e4933ef2b2e2163cd10b650343fd99c3 /drivers/scsi | |
parent | 4b6e5597f4c9ae545a1bd18e830d9f6b4465cadd (diff) | |
download | linux-45e596cd6ead1c4ada74b03067595d7f4502fa6a.tar.bz2 |
scsi: hpsa: Check for null devices in ioaccel submission patch
Reviewed-by: Scott Benesh <scott.benest@microsemi.com>
Reviewed-by: Scott Teel <scott.teel@microsemi.com>
Reviewed-by: Kevin Barnett <kevin.barnett@microsemi.com>
Signed-off-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/hpsa.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c index 82b277be6bf1..e5c02d7cb34b 100644 --- a/drivers/scsi/hpsa.c +++ b/drivers/scsi/hpsa.c @@ -2499,6 +2499,10 @@ static void complete_scsi_command(struct CommandList *cp) } dev = cmd->device->hostdata; + if (!dev) { + cmd->result = DID_NO_CONNECT << 16; + return hpsa_cmd_free_and_done(h, cp, cmd); + } c2 = &h->ioaccel2_cmd_pool[cp->cmdindex]; scsi_dma_unmap(cmd); /* undo the DMA mappings */ @@ -4686,6 +4690,9 @@ static int hpsa_scsi_ioaccel_direct_map(struct ctlr_info *h, struct scsi_cmnd *cmd = c->scsi_cmd; struct hpsa_scsi_dev_t *dev = cmd->device->hostdata; + if (!dev) + return -1; + c->phys_disk = dev; return hpsa_scsi_ioaccel_queue_command(h, c, dev->ioaccel_handle, @@ -4762,6 +4769,12 @@ static int hpsa_scsi_ioaccel2_queue_command(struct ctlr_info *h, u32 len; u32 total_len = 0; + if (!cmd->device) + return -1; + + if (!cmd->device->hostdata) + return -1; + BUG_ON(scsi_sg_count(cmd) > h->maxsgentries); if (fixup_ioaccel_cdb(cdb, &cdb_len)) { @@ -4870,6 +4883,12 @@ static int hpsa_scsi_ioaccel_queue_command(struct ctlr_info *h, struct CommandList *c, u32 ioaccel_handle, u8 *cdb, int cdb_len, u8 *scsi3addr, struct hpsa_scsi_dev_t *phys_disk) { + if (!c->scsi_cmd->device) + return -1; + + if (!c->scsi_cmd->device->hostdata) + return -1; + /* Try to honor the device's queue depth */ if (atomic_inc_return(&phys_disk->ioaccel_cmds_out) > phys_disk->queue_depth) { @@ -4950,6 +4969,9 @@ static int hpsa_scsi_ioaccel_raid_map(struct ctlr_info *h, #endif int offload_to_mirror; + if (!dev) + return -1; + /* check for valid opcode, get LBA and block count */ switch (cmd->cmnd[0]) { case WRITE_6: @@ -5362,6 +5384,9 @@ static int hpsa_ioaccel_submit(struct ctlr_info *h, struct hpsa_scsi_dev_t *dev = cmd->device->hostdata; int rc = IO_ACCEL_INELIGIBLE; + if (!dev) + return SCSI_MLQUEUE_HOST_BUSY; + cmd->host_scribble = (unsigned char *) c; if (dev->offload_enabled) { @@ -5900,6 +5925,9 @@ static void setup_ioaccel2_abort_cmd(struct CommandList *c, struct ctlr_info *h, struct scsi_cmnd *scmd = command_to_abort->scsi_cmd; struct hpsa_scsi_dev_t *dev = scmd->device->hostdata; + if (!dev) + return; + /* * We're overlaying struct hpsa_tmf_struct on top of something which * was allocated as a struct io_accel2_cmd, so we better be sure it @@ -6020,6 +6048,9 @@ static int hpsa_send_abort_ioaccel2(struct ctlr_info *h, struct io_accel2_cmd *c2; dev = abort->scsi_cmd->device->hostdata; + if (!dev) + return -1; + if (!dev->offload_enabled && !dev->hba_ioaccel_enabled) return -1; |