aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/lpfc/lpfc_scsi.c
diff options
context:
space:
mode:
authorJames Smart <James.Smart@Emulex.Com>2008-12-04 22:39:08 -0500
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2008-12-29 12:24:25 -0500
commit109f6ed05aadb7dd1cc9671a63603658d3ba518e (patch)
tree637d09437a45ab0f21e28a30ae4e876d59b6b733 /drivers/scsi/lpfc/lpfc_scsi.c
parent9bad76719ee4fa8c305bb6cba6e19b4ddbe800b2 (diff)
[SCSI] lpfc 8.3.0 : Fix system crash due to uninitialized node access
In the IOCB completion handler, always check if the node is valid before accessing the node object. Added lpfc_initialize_node() to initialize nodes. Signed-off-by: James Smart <James.Smart@emulex.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_scsi.c')
-rw-r--r--drivers/scsi/lpfc/lpfc_scsi.c44
1 files changed, 27 insertions, 17 deletions
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index 6293b6fc65a6..cf6b2d40a923 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -945,7 +945,8 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
945 945
946 lpfc_cmd->result = pIocbOut->iocb.un.ulpWord[4]; 946 lpfc_cmd->result = pIocbOut->iocb.un.ulpWord[4];
947 lpfc_cmd->status = pIocbOut->iocb.ulpStatus; 947 lpfc_cmd->status = pIocbOut->iocb.ulpStatus;
948 atomic_dec(&pnode->cmd_pending); 948 if (pnode && NLP_CHK_NODE_ACT(pnode))
949 atomic_dec(&pnode->cmd_pending);
949 950
950 if (lpfc_cmd->status) { 951 if (lpfc_cmd->status) {
951 if (lpfc_cmd->status == IOSTAT_LOCAL_REJECT && 952 if (lpfc_cmd->status == IOSTAT_LOCAL_REJECT &&
@@ -1035,23 +1036,31 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
1035 time_after(jiffies, lpfc_cmd->start_time + 1036 time_after(jiffies, lpfc_cmd->start_time +
1036 msecs_to_jiffies(vport->cfg_max_scsicmpl_time))) { 1037 msecs_to_jiffies(vport->cfg_max_scsicmpl_time))) {
1037 spin_lock_irqsave(sdev->host->host_lock, flags); 1038 spin_lock_irqsave(sdev->host->host_lock, flags);
1038 if ((pnode->cmd_qdepth > atomic_read(&pnode->cmd_pending) && 1039 if (pnode && NLP_CHK_NODE_ACT(pnode)) {
1039 (atomic_read(&pnode->cmd_pending) > LPFC_MIN_TGT_QDEPTH) && 1040 if (pnode->cmd_qdepth >
1040 ((cmd->cmnd[0] == READ_10) || (cmd->cmnd[0] == WRITE_10)))) 1041 atomic_read(&pnode->cmd_pending) &&
1041 pnode->cmd_qdepth = atomic_read(&pnode->cmd_pending); 1042 (atomic_read(&pnode->cmd_pending) >
1042 1043 LPFC_MIN_TGT_QDEPTH) &&
1043 pnode->last_change_time = jiffies; 1044 ((cmd->cmnd[0] == READ_10) ||
1045 (cmd->cmnd[0] == WRITE_10)))
1046 pnode->cmd_qdepth =
1047 atomic_read(&pnode->cmd_pending);
1048
1049 pnode->last_change_time = jiffies;
1050 }
1044 spin_unlock_irqrestore(sdev->host->host_lock, flags); 1051 spin_unlock_irqrestore(sdev->host->host_lock, flags);
1045 } else if ((pnode->cmd_qdepth < LPFC_MAX_TGT_QDEPTH) && 1052 } else if (pnode && NLP_CHK_NODE_ACT(pnode)) {
1053 if ((pnode->cmd_qdepth < LPFC_MAX_TGT_QDEPTH) &&
1046 time_after(jiffies, pnode->last_change_time + 1054 time_after(jiffies, pnode->last_change_time +
1047 msecs_to_jiffies(LPFC_TGTQ_INTERVAL))) { 1055 msecs_to_jiffies(LPFC_TGTQ_INTERVAL))) {
1048 spin_lock_irqsave(sdev->host->host_lock, flags); 1056 spin_lock_irqsave(sdev->host->host_lock, flags);
1049 pnode->cmd_qdepth += pnode->cmd_qdepth * 1057 pnode->cmd_qdepth += pnode->cmd_qdepth *
1050 LPFC_TGTQ_RAMPUP_PCENT / 100; 1058 LPFC_TGTQ_RAMPUP_PCENT / 100;
1051 if (pnode->cmd_qdepth > LPFC_MAX_TGT_QDEPTH) 1059 if (pnode->cmd_qdepth > LPFC_MAX_TGT_QDEPTH)
1052 pnode->cmd_qdepth = LPFC_MAX_TGT_QDEPTH; 1060 pnode->cmd_qdepth = LPFC_MAX_TGT_QDEPTH;
1053 pnode->last_change_time = jiffies; 1061 pnode->last_change_time = jiffies;
1054 spin_unlock_irqrestore(sdev->host->host_lock, flags); 1062 spin_unlock_irqrestore(sdev->host->host_lock, flags);
1063 }
1055 } 1064 }
1056 1065
1057 lpfc_scsi_unprep_dma_buf(phba, lpfc_cmd); 1066 lpfc_scsi_unprep_dma_buf(phba, lpfc_cmd);
@@ -1536,7 +1545,8 @@ lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *))
1536 cmnd->result = ScsiResult(DID_TRANSPORT_DISRUPTED, 0); 1545 cmnd->result = ScsiResult(DID_TRANSPORT_DISRUPTED, 0);
1537 goto out_fail_command; 1546 goto out_fail_command;
1538 } 1547 }
1539 if (atomic_read(&ndlp->cmd_pending) >= ndlp->cmd_qdepth) 1548 if (vport->cfg_max_scsicmpl_time &&
1549 (atomic_read(&ndlp->cmd_pending) >= ndlp->cmd_qdepth))
1540 goto out_host_busy; 1550 goto out_host_busy;
1541 1551
1542 lpfc_cmd = lpfc_get_scsi_buf(phba); 1552 lpfc_cmd = lpfc_get_scsi_buf(phba);