Patch "scsi: lpfc: Fix memory leak in lpfc_create_port()" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    scsi: lpfc: Fix memory leak in lpfc_create_port()

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     scsi-lpfc-fix-memory-leak-in-lpfc_create_port.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit fbbf55f60c5ce61f1aae8e8751a616f86518c85f
Author: Rafael Mendonca <rafaelmendsr@xxxxxxxxx>
Date:   Fri Sep 16 00:59:07 2022 -0300

    scsi: lpfc: Fix memory leak in lpfc_create_port()
    
    [ Upstream commit dc8e483f684a24cc06e1d5fa958b54db58855093 ]
    
    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>
    Link: https://lore.kernel.org/r/20220916035908.712799-1-rafaelmendsr@xxxxxxxxx
    Reviewed-by: James Smart <jsmart2021@xxxxxxxxx>
    Signed-off-by: Martin K. Petersen <martin.petersen@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 33e33fff8986..48043e1ba485 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -4666,7 +4666,7 @@ lpfc_create_port(struct lpfc_hba *phba, int instance, struct device *dev)
 	rc = lpfc_vmid_res_alloc(phba, vport);
 
 	if (rc)
-		goto out;
+		goto out_put_shost;
 
 	/* Initialize all internally managed lists. */
 	INIT_LIST_HEAD(&vport->fc_nodes);
@@ -4684,16 +4684,17 @@ lpfc_create_port(struct lpfc_hba *phba, int instance, struct device *dev)
 
 	error = scsi_add_host_with_dma(shost, dev, &phba->pcidev->dev);
 	if (error)
-		goto out_put_shost;
+		goto out_free_vmid;
 
 	spin_lock_irq(&phba->port_list_lock);
 	list_add_tail(&vport->listentry, &phba->port_list);
 	spin_unlock_irq(&phba->port_list_lock);
 	return vport;
 
-out_put_shost:
+out_free_vmid:
 	kfree(vport->vmid);
 	bitmap_free(vport->vmid_priority_range);
+out_put_shost:
 	scsi_host_put(shost);
 out:
 	return NULL;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux