Skip to content

Commit

Permalink
scsi: lpfc: Fix memory leak in abnormal exit path from lpfc_eq_create
Browse files Browse the repository at this point in the history
eq create is leaking mailbox memory if it encounters an error.

rework error path to free the memory.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
  • Loading branch information
James Smart authored and Martin K. Petersen committed Jun 18, 2019
1 parent c15e070 commit 04d210c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions drivers/scsi/lpfc/lpfc_sli.c
Original file line number Diff line number Diff line change
Expand Up @@ -14641,8 +14641,10 @@ lpfc_eq_create(struct lpfc_hba *phba, struct lpfc_queue *eq, uint32_t imax)
lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
"0360 Unsupported EQ count. (%d)\n",
eq->entry_count);
if (eq->entry_count < 256)
return -EINVAL;
if (eq->entry_count < 256) {
status = -EINVAL;
goto out;
}
/* fall through - otherwise default to smallest count */
case 256:
bf_set(lpfc_eq_context_count, &eq_create->u.request.context,
Expand Down Expand Up @@ -14694,7 +14696,7 @@ lpfc_eq_create(struct lpfc_hba *phba, struct lpfc_queue *eq, uint32_t imax)
eq->host_index = 0;
eq->notify_interval = LPFC_EQ_NOTIFY_INTRVL;
eq->max_proc_limit = LPFC_EQ_MAX_PROC_LIMIT;

out:
mempool_free(mbox, phba->mbox_mem_pool);
return status;
}
Expand Down

0 comments on commit 04d210c

Please sign in to comment.