Re: [PATCH] scsi: lpfc: Fix memory leak in lpfc_create_port()

From: James Smart
Date: Sun Oct 02 2022 - 12:48:59 EST


On 9/15/2022 8:59 PM, Rafael Mendonca wrote:
Commit 5e633302ace1 ("scsi: lpfc: vmid: Add support for VMID in mailbox
command") introduced allocations for the VMID resources in
lpfc_create_port() after the call to scsi_host_alloc(). Upon failure on the
VMID allocations, the new code would branch to the 'out' label, which
returns NULL without unwinding anything, thus skipping the call to
scsi_host_put().

Fix the problem by creating a separate label 'out_free_vmid' to unwind the
VMID resources and make the 'out_put_shost' label call only
scsi_host_put(), as was done before the introduction of allocations for
VMID.

Fixes: 5e633302ace1 ("scsi: lpfc: vmid: Add support for VMID in mailbox command")
Signed-off-by: Rafael Mendonca <rafaelmendsr@xxxxxxxxx>
---
drivers/scsi/lpfc/lpfc_init.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)


Looks good

Reviewed-by: James Smart <jsmart2021@xxxxxxxxx>

-- james