Commit 14691150 authored by James Smart's avatar James Smart Committed by James Bottomley

[SCSI] lpfc 8.1.11 : Fix Memory leaks

Fix Memory leaks associated with mbox cmds READ_LA, READ_SPARAM, REG_LOGIN
Signed-off-by: default avatarJames Smart <James.Smart@emulex.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent a4bc3379
...@@ -243,6 +243,7 @@ lpfc_cmpl_els_flogi_fabric(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp, ...@@ -243,6 +243,7 @@ lpfc_cmpl_els_flogi_fabric(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp,
struct serv_parm *sp, IOCB_t *irsp) struct serv_parm *sp, IOCB_t *irsp)
{ {
LPFC_MBOXQ_t *mbox; LPFC_MBOXQ_t *mbox;
struct lpfc_dmabuf *mp;
int rc; int rc;
spin_lock_irq(phba->host->host_lock); spin_lock_irq(phba->host->host_lock);
...@@ -307,10 +308,14 @@ lpfc_cmpl_els_flogi_fabric(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp, ...@@ -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); rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT | MBX_STOP_IOCB);
if (rc == MBX_NOT_FINISHED) if (rc == MBX_NOT_FINISHED)
goto fail_free_mbox; goto fail_issue_reg_login;
return 0; 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: fail_free_mbox:
mempool_free(mbox, phba->mbox_mem_pool); mempool_free(mbox, phba->mbox_mem_pool);
fail: fail:
...@@ -1857,6 +1862,7 @@ lpfc_cmpl_els_acc(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb, ...@@ -1857,6 +1862,7 @@ lpfc_cmpl_els_acc(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
IOCB_t *irsp; IOCB_t *irsp;
struct lpfc_nodelist *ndlp; struct lpfc_nodelist *ndlp;
LPFC_MBOXQ_t *mbox = NULL; LPFC_MBOXQ_t *mbox = NULL;
struct lpfc_dmabuf *mp;
irsp = &rspiocb->iocb; irsp = &rspiocb->iocb;
...@@ -1868,6 +1874,11 @@ lpfc_cmpl_els_acc(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb, ...@@ -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 */ /* Check to see if link went down during discovery */
if ((lpfc_els_chk_latt(phba)) || !ndlp) { if ((lpfc_els_chk_latt(phba)) || !ndlp) {
if (mbox) { 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); mempool_free( mbox, phba->mbox_mem_pool);
} }
goto out; goto out;
...@@ -1899,9 +1910,7 @@ lpfc_cmpl_els_acc(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb, ...@@ -1899,9 +1910,7 @@ lpfc_cmpl_els_acc(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
} }
/* NOTE: we should have messages for unsuccessful /* NOTE: we should have messages for unsuccessful
reglogin */ reglogin */
mempool_free( mbox, phba->mbox_mem_pool);
} else { } else {
mempool_free( mbox, phba->mbox_mem_pool);
/* Do not call NO_LIST for lpfc_els_abort'ed ELS cmds */ /* Do not call NO_LIST for lpfc_els_abort'ed ELS cmds */
if (!((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) && if (!((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) &&
((irsp->un.ulpWord[4] == IOERR_SLI_ABORTED) || ((irsp->un.ulpWord[4] == IOERR_SLI_ABORTED) ||
...@@ -1913,6 +1922,12 @@ lpfc_cmpl_els_acc(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb, ...@@ -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: out:
if (ndlp) { if (ndlp) {
......
...@@ -715,6 +715,9 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la) ...@@ -715,6 +715,9 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la)
{ {
int i; int i;
LPFC_MBOXQ_t *sparam_mbox, *cfglink_mbox; LPFC_MBOXQ_t *sparam_mbox, *cfglink_mbox;
struct lpfc_dmabuf *mp;
int rc;
sparam_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); sparam_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
cfglink_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) ...@@ -793,16 +796,27 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la)
if (sparam_mbox) { if (sparam_mbox) {
lpfc_read_sparam(phba, sparam_mbox); lpfc_read_sparam(phba, sparam_mbox);
sparam_mbox->mbox_cmpl = lpfc_mbx_cmpl_read_sparam; 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)); (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) { if (cfglink_mbox) {
phba->hba_state = LPFC_LOCAL_CFG_LINK; phba->hba_state = LPFC_LOCAL_CFG_LINK;
lpfc_config_link(phba, cfglink_mbox); lpfc_config_link(phba, cfglink_mbox);
cfglink_mbox->mbox_cmpl = lpfc_mbx_cmpl_local_config_link; 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)); (MBX_NOWAIT | MBX_STOP_IOCB));
if (rc == MBX_NOT_FINISHED)
mempool_free(cfglink_mbox, phba->mbox_mem_pool);
} }
} }
......
...@@ -611,7 +611,7 @@ lpfc_handle_latt(struct lpfc_hba * phba) ...@@ -611,7 +611,7 @@ lpfc_handle_latt(struct lpfc_hba * phba)
pmb->mbox_cmpl = lpfc_mbx_cmpl_read_la; pmb->mbox_cmpl = lpfc_mbx_cmpl_read_la;
rc = lpfc_sli_issue_mbox (phba, pmb, (MBX_NOWAIT | MBX_STOP_IOCB)); rc = lpfc_sli_issue_mbox (phba, pmb, (MBX_NOWAIT | MBX_STOP_IOCB));
if (rc == MBX_NOT_FINISHED) if (rc == MBX_NOT_FINISHED)
goto lpfc_handle_latt_free_mp; goto lpfc_handle_latt_free_mbuf;
/* Clear Link Attention in HA REG */ /* Clear Link Attention in HA REG */
spin_lock_irq(phba->host->host_lock); spin_lock_irq(phba->host->host_lock);
...@@ -621,6 +621,8 @@ lpfc_handle_latt(struct lpfc_hba * phba) ...@@ -621,6 +621,8 @@ lpfc_handle_latt(struct lpfc_hba * phba)
return; return;
lpfc_handle_latt_free_mbuf:
lpfc_mbuf_free(phba, mp->virt, mp->phys);
lpfc_handle_latt_free_mp: lpfc_handle_latt_free_mp:
kfree(mp); kfree(mp);
lpfc_handle_latt_free_pmb: lpfc_handle_latt_free_pmb:
......
...@@ -739,7 +739,7 @@ lpfc_cmpl_plogi_plogi_issue(struct lpfc_hba * phba, ...@@ -739,7 +739,7 @@ lpfc_cmpl_plogi_plogi_issue(struct lpfc_hba * phba,
uint32_t evt) uint32_t evt)
{ {
struct lpfc_iocbq *cmdiocb, *rspiocb; struct lpfc_iocbq *cmdiocb, *rspiocb;
struct lpfc_dmabuf *pcmd, *prsp; struct lpfc_dmabuf *pcmd, *prsp, *mp;
uint32_t *lp; uint32_t *lp;
IOCB_t *irsp; IOCB_t *irsp;
struct serv_parm *sp; struct serv_parm *sp;
...@@ -829,6 +829,9 @@ lpfc_cmpl_plogi_plogi_issue(struct lpfc_hba * phba, ...@@ -829,6 +829,9 @@ lpfc_cmpl_plogi_plogi_issue(struct lpfc_hba * phba,
NLP_REGLOGIN_LIST); NLP_REGLOGIN_LIST);
return ndlp->nlp_state; 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); mempool_free(mbox, phba->mbox_mem_pool);
} else { } else {
mempool_free(mbox, phba->mbox_mem_pool); mempool_free(mbox, phba->mbox_mem_pool);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment