]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[SCSI] lpfc 8.1.11 : Fix Memory leaks
authorJames Smart <James.Smart@Emulex.Com>
Sat, 2 Dec 2006 18:34:28 +0000 (13:34 -0500)
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>
Sun, 3 Dec 2006 15:29:36 +0000 (09:29 -0600)
Fix Memory leaks associated with mbox cmds READ_LA, READ_SPARAM, REG_LOGIN

Signed-off-by: James Smart <James.Smart@emulex.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
drivers/scsi/lpfc/lpfc_els.c
drivers/scsi/lpfc/lpfc_hbadisc.c
drivers/scsi/lpfc/lpfc_init.c
drivers/scsi/lpfc/lpfc_nportdisc.c

index a47e5ab1ec4dd69a3b16776701a09c1cc6a96d3a..a5f33a0dd4e7b79fb204cff5553d04c71c76177e 100644 (file)
@@ -243,6 +243,7 @@ lpfc_cmpl_els_flogi_fabric(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp,
                struct serv_parm *sp, IOCB_t *irsp)
 {
        LPFC_MBOXQ_t *mbox;
+       struct lpfc_dmabuf *mp;
        int rc;
 
        spin_lock_irq(phba->host->host_lock);
@@ -307,10 +308,14 @@ lpfc_cmpl_els_flogi_fabric(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp,
 
        rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT | MBX_STOP_IOCB);
        if (rc == MBX_NOT_FINISHED)
-               goto fail_free_mbox;
+               goto fail_issue_reg_login;
 
        return 0;
 
+ fail_issue_reg_login:
+       mp = (struct lpfc_dmabuf *) mbox->context1;
+       lpfc_mbuf_free(phba, mp->virt, mp->phys);
+       kfree(mp);
  fail_free_mbox:
        mempool_free(mbox, phba->mbox_mem_pool);
  fail:
@@ -1857,6 +1862,7 @@ lpfc_cmpl_els_acc(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
        IOCB_t *irsp;
        struct lpfc_nodelist *ndlp;
        LPFC_MBOXQ_t *mbox = NULL;
+       struct lpfc_dmabuf *mp;
 
        irsp = &rspiocb->iocb;
 
@@ -1868,6 +1874,11 @@ lpfc_cmpl_els_acc(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
        /* Check to see if link went down during discovery */
        if ((lpfc_els_chk_latt(phba)) || !ndlp) {
                if (mbox) {
+                       mp = (struct lpfc_dmabuf *) mbox->context1;
+                       if (mp) {
+                               lpfc_mbuf_free(phba, mp->virt, mp->phys);
+                               kfree(mp);
+                       }
                        mempool_free( mbox, phba->mbox_mem_pool);
                }
                goto out;
@@ -1899,9 +1910,7 @@ lpfc_cmpl_els_acc(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
                        }
                        /* NOTE: we should have messages for unsuccessful
                           reglogin */
-                       mempool_free( mbox, phba->mbox_mem_pool);
                } else {
-                       mempool_free( mbox, phba->mbox_mem_pool);
                        /* Do not call NO_LIST for lpfc_els_abort'ed ELS cmds */
                        if (!((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) &&
                              ((irsp->un.ulpWord[4] == IOERR_SLI_ABORTED) ||
@@ -1913,6 +1922,12 @@ lpfc_cmpl_els_acc(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
                                }
                        }
                }
+               mp = (struct lpfc_dmabuf *) mbox->context1;
+               if (mp) {
+                       lpfc_mbuf_free(phba, mp->virt, mp->phys);
+                       kfree(mp);
+               }
+               mempool_free(mbox, phba->mbox_mem_pool);
        }
 out:
        if (ndlp) {
index 7c28184ad56d5ca293179cffe3945a99b02631f2..1118b6d49fccc88c717f6d9ef7abc635db2f0cf6 100644 (file)
@@ -715,6 +715,9 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la)
 {
        int i;
        LPFC_MBOXQ_t *sparam_mbox, *cfglink_mbox;
+       struct lpfc_dmabuf *mp;
+       int rc;
+
        sparam_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
        cfglink_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
 
@@ -793,16 +796,27 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la)
        if (sparam_mbox) {
                lpfc_read_sparam(phba, sparam_mbox);
                sparam_mbox->mbox_cmpl = lpfc_mbx_cmpl_read_sparam;
-               lpfc_sli_issue_mbox(phba, sparam_mbox,
+               rc = lpfc_sli_issue_mbox(phba, sparam_mbox,
                                                (MBX_NOWAIT | MBX_STOP_IOCB));
+               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);
+                       if (cfglink_mbox)
+                               mempool_free(cfglink_mbox, phba->mbox_mem_pool);
+                       return;
+               }
        }
 
        if (cfglink_mbox) {
                phba->hba_state = LPFC_LOCAL_CFG_LINK;
                lpfc_config_link(phba, cfglink_mbox);
                cfglink_mbox->mbox_cmpl = lpfc_mbx_cmpl_local_config_link;
-               lpfc_sli_issue_mbox(phba, cfglink_mbox,
+               rc = lpfc_sli_issue_mbox(phba, cfglink_mbox,
                                                (MBX_NOWAIT | MBX_STOP_IOCB));
+               if (rc == MBX_NOT_FINISHED)
+                       mempool_free(cfglink_mbox, phba->mbox_mem_pool);
        }
 }
 
index fd734b0fe95ffd96970d84f6484a06bdb1f51ef8..6b0718573ac5ee88845ba0424ce5b2d302508feb 100644 (file)
@@ -611,7 +611,7 @@ lpfc_handle_latt(struct lpfc_hba * phba)
        pmb->mbox_cmpl = lpfc_mbx_cmpl_read_la;
        rc = lpfc_sli_issue_mbox (phba, pmb, (MBX_NOWAIT | MBX_STOP_IOCB));
        if (rc == MBX_NOT_FINISHED)
-               goto lpfc_handle_latt_free_mp;
+               goto lpfc_handle_latt_free_mbuf;
 
        /* Clear Link Attention in HA REG */
        spin_lock_irq(phba->host->host_lock);
@@ -621,6 +621,8 @@ lpfc_handle_latt(struct lpfc_hba * phba)
 
        return;
 
+lpfc_handle_latt_free_mbuf:
+       lpfc_mbuf_free(phba, mp->virt, mp->phys);
 lpfc_handle_latt_free_mp:
        kfree(mp);
 lpfc_handle_latt_free_pmb:
index 958c330ecaad8f09a2ad2b231f97144036d2af99..0c7e731dc45a6cdba715693d4c72ae0526920a7b 100644 (file)
@@ -739,7 +739,7 @@ lpfc_cmpl_plogi_plogi_issue(struct lpfc_hba * phba,
                            uint32_t evt)
 {
        struct lpfc_iocbq *cmdiocb, *rspiocb;
-       struct lpfc_dmabuf *pcmd, *prsp;
+       struct lpfc_dmabuf *pcmd, *prsp, *mp;
        uint32_t *lp;
        IOCB_t *irsp;
        struct serv_parm *sp;
@@ -829,6 +829,9 @@ lpfc_cmpl_plogi_plogi_issue(struct lpfc_hba * phba,
                                      NLP_REGLOGIN_LIST);
                        return ndlp->nlp_state;
                }
+               mp = (struct lpfc_dmabuf *)mbox->context1;
+               lpfc_mbuf_free(phba, mp->virt, mp->phys);
+               kfree(mp);
                mempool_free(mbox, phba->mbox_mem_pool);
        } else {
                mempool_free(mbox, phba->mbox_mem_pool);