]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
scsi: lpfc: Fix possible memory leak in lpfc_rcv_padisc()
authorJustin Tee <justin.tee@broadcom.com>
Wed, 31 Jan 2024 18:50:57 +0000 (10:50 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 13 Apr 2024 10:59:46 +0000 (12:59 +0200)
[ Upstream commit 2ae917d4bcab80ab304b774d492e2fcd6c52c06b ]

The call to lpfc_sli4_resume_rpi() in lpfc_rcv_padisc() may return an
unsuccessful status.  In such cases, the elsiocb is not issued, the
completion is not called, and thus the elsiocb resource is leaked.

Check return value after calling lpfc_sli4_resume_rpi() and conditionally
release the elsiocb resource.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20240131185112.149731-3-justintee8345@gmail.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/scsi/lpfc/lpfc_nportdisc.c

index 1e22364a31fcf1ad712f4d975621fe4412324f05..d6287c58d50457893af04123cc77ca95ee96fe26 100644 (file)
@@ -784,8 +784,10 @@ lpfc_rcv_padisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
                                /* Save the ELS cmd */
                                elsiocb->drvrTimeout = cmd;
 
-                               lpfc_sli4_resume_rpi(ndlp,
-                                       lpfc_mbx_cmpl_resume_rpi, elsiocb);
+                               if (lpfc_sli4_resume_rpi(ndlp,
+                                               lpfc_mbx_cmpl_resume_rpi,
+                                               elsiocb))
+                                       kfree(elsiocb);
                                goto out;
                        }
                }