Commit da03ded0 authored by Don Brace's avatar Don Brace Committed by Martin K. Petersen

hpsa: fix hpsa_adjust_hpsa_scsi_table

Fix a NULL pointer issue in the driver when devices are removed
during a reset.
Signed-off-by: default avatarDon Brace <don.brace@pmcs.com>
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent c8a6c9a6
...@@ -1663,6 +1663,15 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, ...@@ -1663,6 +1663,15 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h,
int nadded, nremoved; int nadded, nremoved;
struct Scsi_Host *sh = NULL; struct Scsi_Host *sh = NULL;
/*
* A reset can cause a device status to change
* re-schedule the scan to see what happened.
*/
if (h->reset_in_progress) {
h->drv_req_rescan = 1;
return;
}
added = kzalloc(sizeof(*added) * HPSA_MAX_DEVICES, GFP_KERNEL); added = kzalloc(sizeof(*added) * HPSA_MAX_DEVICES, GFP_KERNEL);
removed = kzalloc(sizeof(*removed) * HPSA_MAX_DEVICES, GFP_KERNEL); removed = kzalloc(sizeof(*removed) * HPSA_MAX_DEVICES, GFP_KERNEL);
...@@ -1771,6 +1780,10 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, ...@@ -1771,6 +1780,10 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h,
goto free_and_out; goto free_and_out;
sh = h->scsi_host; sh = h->scsi_host;
if (sh == NULL) {
dev_warn(&h->pdev->dev, "%s: scsi_host is null\n", __func__);
goto free_and_out;
}
/* Notify scsi mid layer of any removed devices */ /* Notify scsi mid layer of any removed devices */
for (i = 0; i < nremoved; i++) { for (i = 0; i < nremoved; i++) {
if (removed[i] == NULL) if (removed[i] == NULL)
...@@ -5234,12 +5247,15 @@ static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd) ...@@ -5234,12 +5247,15 @@ static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd)
hpsa_show_dev_msg(KERN_WARNING, h, dev, "resetting"); hpsa_show_dev_msg(KERN_WARNING, h, dev, "resetting");
h->reset_in_progress = 1;
/* send a reset to the SCSI LUN which the command was sent to */ /* send a reset to the SCSI LUN which the command was sent to */
rc = hpsa_do_reset(h, dev, dev->scsi3addr, HPSA_RESET_TYPE_LUN, rc = hpsa_do_reset(h, dev, dev->scsi3addr, HPSA_RESET_TYPE_LUN,
DEFAULT_REPLY_QUEUE); DEFAULT_REPLY_QUEUE);
snprintf(msg, sizeof(msg), "reset %s", snprintf(msg, sizeof(msg), "reset %s",
rc == 0 ? "completed successfully" : "failed"); rc == 0 ? "completed successfully" : "failed");
hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); hpsa_show_dev_msg(KERN_WARNING, h, dev, msg);
h->reset_in_progress = 0;
return rc == 0 ? SUCCESS : FAILED; return rc == 0 ? SUCCESS : FAILED;
} }
......
...@@ -271,6 +271,7 @@ struct ctlr_info { ...@@ -271,6 +271,7 @@ struct ctlr_info {
wait_queue_head_t abort_cmd_wait_queue; wait_queue_head_t abort_cmd_wait_queue;
wait_queue_head_t event_sync_wait_queue; wait_queue_head_t event_sync_wait_queue;
struct mutex reset_mutex; struct mutex reset_mutex;
u8 reset_in_progress;
}; };
struct offline_device_entry { struct offline_device_entry {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment