aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorJames Smart <james.smart@emulex.com>2010-02-26 14:12:57 -0500
committerJames Bottomley <James.Bottomley@suse.de>2010-03-03 08:38:34 -0500
commit9f1177a3f8eee22427eb97e6e00b62ff0be2871f (patch)
treea004d94e7d406f791e420eec7c02c2d5bcf70587 /drivers/scsi
parent43aebfa12e7631124472237dc945c27af54ca646 (diff)
[SCSI] lpfc 8.3.10: Fix Initialization issues
- Add NULL checks to the pointers for the config_async mailbox and dump_wakeup_params mailbox. - Add code to check return value of lpfc_read_sparams everywhere and handle failures appropriately. Signed-off-by: James Smart <james.smart@emulex.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/lpfc/lpfc_hbadisc.c32
-rw-r--r--drivers/scsi/lpfc/lpfc_init.c19
-rw-r--r--drivers/scsi/lpfc/lpfc_sli.c8
-rw-r--r--drivers/scsi/lpfc/lpfc_vport.c7
4 files changed, 48 insertions, 18 deletions
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index 2359d0bfb734..e58d8aeec09e 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -2024,8 +2024,6 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la)
2024 int rc; 2024 int rc;
2025 struct fcf_record *fcf_record; 2025 struct fcf_record *fcf_record;
2026 2026
2027 sparam_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
2028
2029 spin_lock_irq(&phba->hbalock); 2027 spin_lock_irq(&phba->hbalock);
2030 switch (la->UlnkSpeed) { 2028 switch (la->UlnkSpeed) {
2031 case LA_1GHZ_LINK: 2029 case LA_1GHZ_LINK:
@@ -2117,18 +2115,24 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la)
2117 spin_unlock_irq(&phba->hbalock); 2115 spin_unlock_irq(&phba->hbalock);
2118 2116
2119 lpfc_linkup(phba); 2117 lpfc_linkup(phba);
2120 if (sparam_mbox) { 2118 sparam_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
2121 lpfc_read_sparam(phba, sparam_mbox, 0); 2119 if (!sparam_mbox)
2122 sparam_mbox->vport = vport; 2120 goto out;
2123 sparam_mbox->mbox_cmpl = lpfc_mbx_cmpl_read_sparam; 2121
2124 rc = lpfc_sli_issue_mbox(phba, sparam_mbox, MBX_NOWAIT); 2122 rc = lpfc_read_sparam(phba, sparam_mbox, 0);
2125 if (rc == MBX_NOT_FINISHED) { 2123 if (rc) {
2126 mp = (struct lpfc_dmabuf *) sparam_mbox->context1; 2124 mempool_free(sparam_mbox, phba->mbox_mem_pool);
2127 lpfc_mbuf_free(phba, mp->virt, mp->phys); 2125 goto out;
2128 kfree(mp); 2126 }
2129 mempool_free(sparam_mbox, phba->mbox_mem_pool); 2127 sparam_mbox->vport = vport;
2130 goto out; 2128 sparam_mbox->mbox_cmpl = lpfc_mbx_cmpl_read_sparam;
2131 } 2129 rc = lpfc_sli_issue_mbox(phba, sparam_mbox, MBX_NOWAIT);
2130 if (rc == MBX_NOT_FINISHED) {
2131 mp = (struct lpfc_dmabuf *) sparam_mbox->context1;
2132 lpfc_mbuf_free(phba, mp->virt, mp->phys);
2133 kfree(mp);
2134 mempool_free(sparam_mbox, phba->mbox_mem_pool);
2135 goto out;
2132 } 2136 }
2133 2137
2134 if (!(phba->hba_flag & HBA_FCOE_SUPPORT)) { 2138 if (!(phba->hba_flag & HBA_FCOE_SUPPORT)) {
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index d29ac7c317d9..b64cecafa7ab 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -350,7 +350,12 @@ lpfc_config_port_post(struct lpfc_hba *phba)
350 mb = &pmb->u.mb; 350 mb = &pmb->u.mb;
351 351
352 /* Get login parameters for NID. */ 352 /* Get login parameters for NID. */
353 lpfc_read_sparam(phba, pmb, 0); 353 rc = lpfc_read_sparam(phba, pmb, 0);
354 if (rc) {
355 mempool_free(pmb, phba->mbox_mem_pool);
356 return -ENOMEM;
357 }
358
354 pmb->vport = vport; 359 pmb->vport = vport;
355 if (lpfc_sli_issue_mbox(phba, pmb, MBX_POLL) != MBX_SUCCESS) { 360 if (lpfc_sli_issue_mbox(phba, pmb, MBX_POLL) != MBX_SUCCESS) {
356 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 361 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
@@ -359,7 +364,7 @@ lpfc_config_port_post(struct lpfc_hba *phba)
359 mb->mbxCommand, mb->mbxStatus); 364 mb->mbxCommand, mb->mbxStatus);
360 phba->link_state = LPFC_HBA_ERROR; 365 phba->link_state = LPFC_HBA_ERROR;
361 mp = (struct lpfc_dmabuf *) pmb->context1; 366 mp = (struct lpfc_dmabuf *) pmb->context1;
362 mempool_free( pmb, phba->mbox_mem_pool); 367 mempool_free(pmb, phba->mbox_mem_pool);
363 lpfc_mbuf_free(phba, mp->virt, mp->phys); 368 lpfc_mbuf_free(phba, mp->virt, mp->phys);
364 kfree(mp); 369 kfree(mp);
365 return -EIO; 370 return -EIO;
@@ -571,6 +576,11 @@ lpfc_config_port_post(struct lpfc_hba *phba)
571 } 576 }
572 /* MBOX buffer will be freed in mbox compl */ 577 /* MBOX buffer will be freed in mbox compl */
573 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); 578 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
579 if (!pmb) {
580 phba->link_state = LPFC_HBA_ERROR;
581 return -ENOMEM;
582 }
583
574 lpfc_config_async(phba, pmb, LPFC_ELS_RING); 584 lpfc_config_async(phba, pmb, LPFC_ELS_RING);
575 pmb->mbox_cmpl = lpfc_config_async_cmpl; 585 pmb->mbox_cmpl = lpfc_config_async_cmpl;
576 pmb->vport = phba->pport; 586 pmb->vport = phba->pport;
@@ -588,6 +598,11 @@ lpfc_config_port_post(struct lpfc_hba *phba)
588 598
589 /* Get Option rom version */ 599 /* Get Option rom version */
590 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); 600 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
601 if (!pmb) {
602 phba->link_state = LPFC_HBA_ERROR;
603 return -ENOMEM;
604 }
605
591 lpfc_dump_wakeup_param(phba, pmb); 606 lpfc_dump_wakeup_param(phba, pmb);
592 pmb->mbox_cmpl = lpfc_dump_wakeup_param_cmpl; 607 pmb->mbox_cmpl = lpfc_dump_wakeup_param_cmpl;
593 pmb->vport = phba->pport; 608 pmb->vport = phba->pport;
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 35e3b96d4e07..d51ee7e3273b 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -4388,7 +4388,13 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba)
4388 spin_unlock_irq(&phba->hbalock); 4388 spin_unlock_irq(&phba->hbalock);
4389 4389
4390 /* Read the port's service parameters. */ 4390 /* Read the port's service parameters. */
4391 lpfc_read_sparam(phba, mboxq, vport->vpi); 4391 rc = lpfc_read_sparam(phba, mboxq, vport->vpi);
4392 if (rc) {
4393 phba->link_state = LPFC_HBA_ERROR;
4394 rc = -ENOMEM;
4395 goto out_free_vpd;
4396 }
4397
4392 mboxq->vport = vport; 4398 mboxq->vport = vport;
4393 rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_POLL); 4399 rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_POLL);
4394 mp = (struct lpfc_dmabuf *) mboxq->context1; 4400 mp = (struct lpfc_dmabuf *) mboxq->context1;
diff --git a/drivers/scsi/lpfc/lpfc_vport.c b/drivers/scsi/lpfc/lpfc_vport.c
index dc86e873102a..869f76cbc58a 100644
--- a/drivers/scsi/lpfc/lpfc_vport.c
+++ b/drivers/scsi/lpfc/lpfc_vport.c
@@ -123,7 +123,12 @@ lpfc_vport_sparm(struct lpfc_hba *phba, struct lpfc_vport *vport)
123 } 123 }
124 mb = &pmb->u.mb; 124 mb = &pmb->u.mb;
125 125
126 lpfc_read_sparam(phba, pmb, vport->vpi); 126 rc = lpfc_read_sparam(phba, pmb, vport->vpi);
127 if (rc) {
128 mempool_free(pmb, phba->mbox_mem_pool);
129 return -ENOMEM;
130 }
131
127 /* 132 /*
128 * Grab buffer pointer and clear context1 so we can use 133 * Grab buffer pointer and clear context1 so we can use
129 * lpfc_sli_issue_box_wait 134 * lpfc_sli_issue_box_wait