diff options
author | James Smart <james.smart@emulex.com> | 2010-02-12 14:43:01 -0500 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2010-02-17 18:41:19 -0500 |
commit | 72100cc43262fa39821b3debc04be1a7a17b3428 (patch) | |
tree | 2f313571ee9c9cf4d4a16f2a6e69f82c569b9757 /drivers/scsi/lpfc/lpfc_hbadisc.c | |
parent | 84d1b006978e78e27f22beb5cfbc4d349bac6df7 (diff) |
[SCSI] lpfc 8.3.9: Fix locking and memory issues
- Use the hbalock when changing the fc_flag.
- Use the host_lock when changeing the sli_flag.
- Prevent NULL pointer dereference after dma_alloc_coherent failure.
Signed-off-by: James Smart <james.smart@emulex.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_hbadisc.c')
-rw-r--r-- | drivers/scsi/lpfc/lpfc_hbadisc.c | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c index b890e2dc15db..2359d0bfb734 100644 --- a/drivers/scsi/lpfc/lpfc_hbadisc.c +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c | |||
@@ -757,11 +757,13 @@ lpfc_linkdown(struct lpfc_hba *phba) | |||
757 | 757 | ||
758 | spin_lock_irq(&phba->hbalock); | 758 | spin_lock_irq(&phba->hbalock); |
759 | phba->fcf.fcf_flag &= ~(FCF_AVAILABLE | FCF_SCAN_DONE); | 759 | phba->fcf.fcf_flag &= ~(FCF_AVAILABLE | FCF_SCAN_DONE); |
760 | spin_unlock_irq(&phba->hbalock); | ||
760 | if (phba->link_state > LPFC_LINK_DOWN) { | 761 | if (phba->link_state > LPFC_LINK_DOWN) { |
761 | phba->link_state = LPFC_LINK_DOWN; | 762 | phba->link_state = LPFC_LINK_DOWN; |
763 | spin_lock_irq(shost->host_lock); | ||
762 | phba->pport->fc_flag &= ~FC_LBIT; | 764 | phba->pport->fc_flag &= ~FC_LBIT; |
765 | spin_unlock_irq(shost->host_lock); | ||
763 | } | 766 | } |
764 | spin_unlock_irq(&phba->hbalock); | ||
765 | vports = lpfc_create_vport_work_array(phba); | 767 | vports = lpfc_create_vport_work_array(phba); |
766 | if (vports != NULL) | 768 | if (vports != NULL) |
767 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { | 769 | for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) { |
@@ -1802,6 +1804,8 @@ lpfc_init_vpi_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | |||
1802 | { | 1804 | { |
1803 | struct lpfc_vport *vport = mboxq->vport; | 1805 | struct lpfc_vport *vport = mboxq->vport; |
1804 | struct lpfc_nodelist *ndlp; | 1806 | struct lpfc_nodelist *ndlp; |
1807 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); | ||
1808 | |||
1805 | if (mboxq->u.mb.mbxStatus) { | 1809 | if (mboxq->u.mb.mbxStatus) { |
1806 | lpfc_printf_vlog(vport, KERN_ERR, | 1810 | lpfc_printf_vlog(vport, KERN_ERR, |
1807 | LOG_MBOX, | 1811 | LOG_MBOX, |
@@ -1811,9 +1815,9 @@ lpfc_init_vpi_cmpl(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | |||
1811 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); | 1815 | lpfc_vport_set_state(vport, FC_VPORT_FAILED); |
1812 | return; | 1816 | return; |
1813 | } | 1817 | } |
1814 | spin_lock_irq(&phba->hbalock); | 1818 | spin_lock_irq(shost->host_lock); |
1815 | vport->fc_flag &= ~FC_VPORT_NEEDS_INIT_VPI; | 1819 | vport->fc_flag &= ~FC_VPORT_NEEDS_INIT_VPI; |
1816 | spin_unlock_irq(&phba->hbalock); | 1820 | spin_unlock_irq(shost->host_lock); |
1817 | 1821 | ||
1818 | /* If this port is physical port or FDISC is done, do reg_vpi */ | 1822 | /* If this port is physical port or FDISC is done, do reg_vpi */ |
1819 | if ((phba->pport == vport) || (vport->port_state == LPFC_FDISC)) { | 1823 | if ((phba->pport == vport) || (vport->port_state == LPFC_FDISC)) { |
@@ -1924,6 +1928,7 @@ lpfc_mbx_cmpl_reg_vfi(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | |||
1924 | { | 1928 | { |
1925 | struct lpfc_dmabuf *dmabuf = mboxq->context1; | 1929 | struct lpfc_dmabuf *dmabuf = mboxq->context1; |
1926 | struct lpfc_vport *vport = mboxq->vport; | 1930 | struct lpfc_vport *vport = mboxq->vport; |
1931 | struct Scsi_Host *shost = lpfc_shost_from_vport(vport); | ||
1927 | 1932 | ||
1928 | if (mboxq->u.mb.mbxStatus) { | 1933 | if (mboxq->u.mb.mbxStatus) { |
1929 | lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX, | 1934 | lpfc_printf_vlog(vport, KERN_ERR, LOG_MBOX, |
@@ -1941,10 +1946,11 @@ lpfc_mbx_cmpl_reg_vfi(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | |||
1941 | goto fail_free_mem; | 1946 | goto fail_free_mem; |
1942 | } | 1947 | } |
1943 | /* The VPI is implicitly registered when the VFI is registered */ | 1948 | /* The VPI is implicitly registered when the VFI is registered */ |
1949 | spin_lock_irq(shost->host_lock); | ||
1944 | vport->vpi_state |= LPFC_VPI_REGISTERED; | 1950 | vport->vpi_state |= LPFC_VPI_REGISTERED; |
1945 | vport->fc_flag |= FC_VFI_REGISTERED; | 1951 | vport->fc_flag |= FC_VFI_REGISTERED; |
1946 | |||
1947 | vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI; | 1952 | vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI; |
1953 | spin_unlock_irq(shost->host_lock); | ||
1948 | 1954 | ||
1949 | if (vport->port_state == LPFC_FABRIC_CFG_LINK) { | 1955 | if (vport->port_state == LPFC_FABRIC_CFG_LINK) { |
1950 | lpfc_start_fdiscs(phba); | 1956 | lpfc_start_fdiscs(phba); |
@@ -2269,10 +2275,12 @@ lpfc_mbx_cmpl_read_la(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | |||
2269 | } | 2275 | } |
2270 | 2276 | ||
2271 | phba->fc_eventTag = la->eventTag; | 2277 | phba->fc_eventTag = la->eventTag; |
2278 | spin_lock_irq(&phba->hbalock); | ||
2272 | if (la->mm) | 2279 | if (la->mm) |
2273 | phba->sli.sli_flag |= LPFC_MENLO_MAINT; | 2280 | phba->sli.sli_flag |= LPFC_MENLO_MAINT; |
2274 | else | 2281 | else |
2275 | phba->sli.sli_flag &= ~LPFC_MENLO_MAINT; | 2282 | phba->sli.sli_flag &= ~LPFC_MENLO_MAINT; |
2283 | spin_unlock_irq(&phba->hbalock); | ||
2276 | 2284 | ||
2277 | phba->link_events++; | 2285 | phba->link_events++; |
2278 | if (la->attType == AT_LINK_UP && (!la->mm)) { | 2286 | if (la->attType == AT_LINK_UP && (!la->mm)) { |
@@ -2401,10 +2409,10 @@ lpfc_mbx_cmpl_unreg_vpi(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | |||
2401 | mb->mbxStatus); | 2409 | mb->mbxStatus); |
2402 | break; | 2410 | break; |
2403 | } | 2411 | } |
2404 | spin_lock_irq(&phba->hbalock); | 2412 | spin_lock_irq(shost->host_lock); |
2405 | vport->vpi_state &= ~LPFC_VPI_REGISTERED; | 2413 | vport->vpi_state &= ~LPFC_VPI_REGISTERED; |
2406 | vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; | 2414 | vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; |
2407 | spin_unlock_irq(&phba->hbalock); | 2415 | spin_unlock_irq(shost->host_lock); |
2408 | vport->unreg_vpi_cmpl = VPORT_OK; | 2416 | vport->unreg_vpi_cmpl = VPORT_OK; |
2409 | mempool_free(pmb, phba->mbox_mem_pool); | 2417 | mempool_free(pmb, phba->mbox_mem_pool); |
2410 | /* | 2418 | /* |
@@ -2462,8 +2470,10 @@ lpfc_mbx_cmpl_reg_vpi(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) | |||
2462 | goto out; | 2470 | goto out; |
2463 | } | 2471 | } |
2464 | 2472 | ||
2473 | spin_lock_irq(shost->host_lock); | ||
2465 | vport->vpi_state |= LPFC_VPI_REGISTERED; | 2474 | vport->vpi_state |= LPFC_VPI_REGISTERED; |
2466 | vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI; | 2475 | vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI; |
2476 | spin_unlock_irq(shost->host_lock); | ||
2467 | vport->num_disc_nodes = 0; | 2477 | vport->num_disc_nodes = 0; |
2468 | /* go thru NPR list and issue ELS PLOGIs */ | 2478 | /* go thru NPR list and issue ELS PLOGIs */ |
2469 | if (vport->fc_npr_cnt) | 2479 | if (vport->fc_npr_cnt) |
@@ -4620,6 +4630,7 @@ lpfc_unregister_fcf_prep(struct lpfc_hba *phba) | |||
4620 | LPFC_MBOXQ_t *mbox; | 4630 | LPFC_MBOXQ_t *mbox; |
4621 | struct lpfc_vport **vports; | 4631 | struct lpfc_vport **vports; |
4622 | struct lpfc_nodelist *ndlp; | 4632 | struct lpfc_nodelist *ndlp; |
4633 | struct Scsi_Host *shost; | ||
4623 | int i, rc; | 4634 | int i, rc; |
4624 | 4635 | ||
4625 | /* Unregister RPIs */ | 4636 | /* Unregister RPIs */ |
@@ -4638,10 +4649,11 @@ lpfc_unregister_fcf_prep(struct lpfc_hba *phba) | |||
4638 | if (ndlp) | 4649 | if (ndlp) |
4639 | lpfc_cancel_retry_delay_tmo(vports[i], ndlp); | 4650 | lpfc_cancel_retry_delay_tmo(vports[i], ndlp); |
4640 | lpfc_mbx_unreg_vpi(vports[i]); | 4651 | lpfc_mbx_unreg_vpi(vports[i]); |
4641 | spin_lock_irq(&phba->hbalock); | 4652 | shost = lpfc_shost_from_vport(vports[i]); |
4653 | spin_lock_irq(shost->host_lock); | ||
4642 | vports[i]->fc_flag |= FC_VPORT_NEEDS_INIT_VPI; | 4654 | vports[i]->fc_flag |= FC_VPORT_NEEDS_INIT_VPI; |
4643 | vports[i]->vpi_state &= ~LPFC_VPI_REGISTERED; | 4655 | vports[i]->vpi_state &= ~LPFC_VPI_REGISTERED; |
4644 | spin_unlock_irq(&phba->hbalock); | 4656 | spin_unlock_irq(shost->host_lock); |
4645 | } | 4657 | } |
4646 | lpfc_destroy_vport_work_array(phba, vports); | 4658 | lpfc_destroy_vport_work_array(phba, vports); |
4647 | 4659 | ||
@@ -4671,9 +4683,10 @@ lpfc_unregister_fcf_prep(struct lpfc_hba *phba) | |||
4671 | return -EIO; | 4683 | return -EIO; |
4672 | } | 4684 | } |
4673 | 4685 | ||
4674 | spin_lock_irq(&phba->hbalock); | 4686 | shost = lpfc_shost_from_vport(phba->pport); |
4687 | spin_lock_irq(shost->host_lock); | ||
4675 | phba->pport->fc_flag &= ~FC_VFI_REGISTERED; | 4688 | phba->pport->fc_flag &= ~FC_VFI_REGISTERED; |
4676 | spin_unlock_irq(&phba->hbalock); | 4689 | spin_unlock_irq(shost->host_lock); |
4677 | 4690 | ||
4678 | return 0; | 4691 | return 0; |
4679 | } | 4692 | } |