Skip to content

Commit 7217e6e

Browse files
sherllymartinkpetersen
authored andcommitted
scsi: lpfc: Fix lpfc_nodelist leak when processing unsolicited event
In order to create or activate a new node, lpfc_els_unsol_buffer() invokes lpfc_nlp_init() or lpfc_enable_node() or lpfc_nlp_get(), all of them will return a reference of the specified lpfc_nodelist object to "ndlp" with increased refcnt. When lpfc_els_unsol_buffer() returns, local variable "ndlp" becomes invalid, so the refcount should be decreased to keep refcount balanced. The reference counting issue happens in one exception handling path of lpfc_els_unsol_buffer(). When "ndlp" in DEV_LOSS, the function forgets to decrease the refcnt increased by lpfc_nlp_init() or lpfc_enable_node() or lpfc_nlp_get(), causing a refcnt leak. Fix this issue by calling lpfc_nlp_put() when "ndlp" in DEV_LOSS. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Daniel Wagner <[email protected]> Reviewed-by: James Smart <[email protected]> Signed-off-by: Xiyu Yang <[email protected]> Signed-off-by: Xin Tan <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 9d7464b commit 7217e6e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/scsi/lpfc/lpfc_els.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8508,6 +8508,8 @@ lpfc_els_unsol_buffer(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
85088508
spin_lock_irq(shost->host_lock);
85098509
if (ndlp->nlp_flag & NLP_IN_DEV_LOSS) {
85108510
spin_unlock_irq(shost->host_lock);
8511+
if (newnode)
8512+
lpfc_nlp_put(ndlp);
85118513
goto dropit;
85128514
}
85138515
spin_unlock_irq(shost->host_lock);

0 commit comments

Comments
 (0)