[SCSI] lpfc 8.3.10: Fix Initialization issues
authorJames Smart <james.smart@emulex.com>
Fri, 26 Feb 2010 19:12:57 +0000 (14:12 -0500)
committerJames Bottomley <James.Bottomley@suse.de>
Wed, 3 Mar 2010 13:38:34 +0000 (19:08 +0530)
- 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>
drivers/scsi/lpfc/lpfc_hbadisc.c
drivers/scsi/lpfc/lpfc_init.c
drivers/scsi/lpfc/lpfc_sli.c
drivers/scsi/lpfc/lpfc_vport.c

index 2359d0bfb734f0cd352ca8c68560a07757a8c47c..e58d8aeec09eba439d78e9feca18b8dd967f17ff 100644 (file)
@@ -2024,8 +2024,6 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la)
        int rc;
        struct fcf_record *fcf_record;
 
-       sparam_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
-
        spin_lock_irq(&phba->hbalock);
        switch (la->UlnkSpeed) {
        case LA_1GHZ_LINK:
@@ -2117,18 +2115,24 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la)
        spin_unlock_irq(&phba->hbalock);
 
        lpfc_linkup(phba);
-       if (sparam_mbox) {
-               lpfc_read_sparam(phba, sparam_mbox, 0);
-               sparam_mbox->vport = vport;
-               sparam_mbox->mbox_cmpl = lpfc_mbx_cmpl_read_sparam;
-               rc = lpfc_sli_issue_mbox(phba, sparam_mbox, MBX_NOWAIT);
-               if (rc == MBX_NOT_FINISHED) {
-                       mp = (struct lpfc_dmabuf *) sparam_mbox->context1;
-                       lpfc_mbuf_free(phba, mp->virt, mp->phys);
-                       kfree(mp);
-                       mempool_free(sparam_mbox, phba->mbox_mem_pool);
-                       goto out;
-               }
+       sparam_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
+       if (!sparam_mbox)
+               goto out;
+
+       rc = lpfc_read_sparam(phba, sparam_mbox, 0);
+       if (rc) {
+               mempool_free(sparam_mbox, phba->mbox_mem_pool);
+               goto out;
+       }
+       sparam_mbox->vport = vport;
+       sparam_mbox->mbox_cmpl = lpfc_mbx_cmpl_read_sparam;
+       rc = lpfc_sli_issue_mbox(phba, sparam_mbox, MBX_NOWAIT);
+       if (rc == MBX_NOT_FINISHED) {
+               mp = (struct lpfc_dmabuf *) sparam_mbox->context1;
+               lpfc_mbuf_free(phba, mp->virt, mp->phys);
+               kfree(mp);
+               mempool_free(sparam_mbox, phba->mbox_mem_pool);
+               goto out;
        }
 
        if (!(phba->hba_flag & HBA_FCOE_SUPPORT)) {
index d29ac7c317d9d7324b13807f2329615320c2d37f..b64cecafa7ab46759f94c56fd0f17a5f21c348f0 100644 (file)
@@ -350,7 +350,12 @@ lpfc_config_port_post(struct lpfc_hba *phba)
        mb = &pmb->u.mb;
 
        /* Get login parameters for NID.  */
-       lpfc_read_sparam(phba, pmb, 0);
+       rc = lpfc_read_sparam(phba, pmb, 0);
+       if (rc) {
+               mempool_free(pmb, phba->mbox_mem_pool);
+               return -ENOMEM;
+       }
+
        pmb->vport = vport;
        if (lpfc_sli_issue_mbox(phba, pmb, MBX_POLL) != MBX_SUCCESS) {
                lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
@@ -359,7 +364,7 @@ lpfc_config_port_post(struct lpfc_hba *phba)
                                mb->mbxCommand, mb->mbxStatus);
                phba->link_state = LPFC_HBA_ERROR;
                mp = (struct lpfc_dmabuf *) pmb->context1;
-               mempool_free( pmb, phba->mbox_mem_pool);
+               mempool_free(pmb, phba->mbox_mem_pool);
                lpfc_mbuf_free(phba, mp->virt, mp->phys);
                kfree(mp);
                return -EIO;
@@ -571,6 +576,11 @@ lpfc_config_port_post(struct lpfc_hba *phba)
        }
        /* MBOX buffer will be freed in mbox compl */
        pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
+       if (!pmb) {
+               phba->link_state = LPFC_HBA_ERROR;
+               return -ENOMEM;
+       }
+
        lpfc_config_async(phba, pmb, LPFC_ELS_RING);
        pmb->mbox_cmpl = lpfc_config_async_cmpl;
        pmb->vport = phba->pport;
@@ -588,6 +598,11 @@ lpfc_config_port_post(struct lpfc_hba *phba)
 
        /* Get Option rom version */
        pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
+       if (!pmb) {
+               phba->link_state = LPFC_HBA_ERROR;
+               return -ENOMEM;
+       }
+
        lpfc_dump_wakeup_param(phba, pmb);
        pmb->mbox_cmpl = lpfc_dump_wakeup_param_cmpl;
        pmb->vport = phba->pport;
index 35e3b96d4e079d2ae519dae5bb891fb955e9bcd6..d51ee7e3273bd7548f3a3f4b49177ea1c466c258 100644 (file)
@@ -4388,7 +4388,13 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba)
        spin_unlock_irq(&phba->hbalock);
 
        /* Read the port's service parameters. */
-       lpfc_read_sparam(phba, mboxq, vport->vpi);
+       rc = lpfc_read_sparam(phba, mboxq, vport->vpi);
+       if (rc) {
+               phba->link_state = LPFC_HBA_ERROR;
+               rc = -ENOMEM;
+               goto out_free_vpd;
+       }
+
        mboxq->vport = vport;
        rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_POLL);
        mp = (struct lpfc_dmabuf *) mboxq->context1;
index dc86e873102a1763a445e285b9d671d7411058a8..869f76cbc58a8eb3bb3bc982b3e5f382043bd404 100644 (file)
@@ -123,7 +123,12 @@ lpfc_vport_sparm(struct lpfc_hba *phba, struct lpfc_vport *vport)
        }
        mb = &pmb->u.mb;
 
-       lpfc_read_sparam(phba, pmb, vport->vpi);
+       rc = lpfc_read_sparam(phba, pmb, vport->vpi);
+       if (rc) {
+               mempool_free(pmb, phba->mbox_mem_pool);
+               return -ENOMEM;
+       }
+
        /*
         * Grab buffer pointer and clear context1 so we can use
         * lpfc_sli_issue_box_wait