Skip to content

Commit 0be3109

Browse files
Dan Carpentermartinkpetersen
authored andcommitted
scsi: lpfc: Fix ancient double free
The "pmb" pointer is freed at the start of the function and then freed again in the error handling code. Link: https://lore.kernel.org/r/YA6E8rO51hE56SVw@mwanda Fixes: 92d7f7b ("[SCSI] lpfc: NPIV: add NPIV support on top of SLI-3") Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent bc2b4e6 commit 0be3109

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

drivers/scsi/lpfc/lpfc_hbadisc.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,13 +1155,14 @@ lpfc_mbx_cmpl_local_config_link(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
11551155
struct lpfc_vport *vport = pmb->vport;
11561156
LPFC_MBOXQ_t *sparam_mb;
11571157
struct lpfc_dmabuf *sparam_mp;
1158+
u16 status = pmb->u.mb.mbxStatus;
11581159
int rc;
11591160

1160-
if (pmb->u.mb.mbxStatus)
1161-
goto out;
1162-
11631161
mempool_free(pmb, phba->mbox_mem_pool);
11641162

1163+
if (status)
1164+
goto out;
1165+
11651166
/* don't perform discovery for SLI4 loopback diagnostic test */
11661167
if ((phba->sli_rev == LPFC_SLI_REV4) &&
11671168
!(phba->hba_flag & HBA_FCOE_MODE) &&
@@ -1224,12 +1225,10 @@ lpfc_mbx_cmpl_local_config_link(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
12241225

12251226
out:
12261227
lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
1227-
"0306 CONFIG_LINK mbxStatus error x%x "
1228-
"HBA state x%x\n",
1229-
pmb->u.mb.mbxStatus, vport->port_state);
1230-
sparam_out:
1231-
mempool_free(pmb, phba->mbox_mem_pool);
1228+
"0306 CONFIG_LINK mbxStatus error x%x HBA state x%x\n",
1229+
status, vport->port_state);
12321230

1231+
sparam_out:
12331232
lpfc_linkdown(phba);
12341233

12351234
lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,

0 commit comments

Comments
 (0)