]> git.baikalelectronics.ru Git - kernel.git/commitdiff
scsi: mpi3mr: Fix sas_hba.phy memory leak in mpi3mr_remove()
authorTomas Henzl <thenzl@redhat.com>
Thu, 2 Mar 2023 23:43:34 +0000 (00:43 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Mar 2023 12:33:41 +0000 (13:33 +0100)
[ Upstream commit 1aacb26a1aad3b84cf1b50823e17f289fa8d61fa ]

Free mrioc->sas_hba.phy at .remove.

Fixes: 33266bf2c87e ("scsi: mpi3mr: Add helper functions to manage device's port")
Signed-off-by: Tomas Henzl <thenzl@redhat.com>
Link: https://lore.kernel.org/r/20230302234336.25456-5-thenzl@redhat.com
Acked-by: Sathya Prakash Veerichetty <sathya.prakash@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/scsi/mpi3mr/mpi3mr_os.c

index 5032b0b5186d454d319e597f626209222abf6c1f..5698e7b90f852a4032ff55e63d14d85e4f048dd1 100644 (file)
@@ -5127,6 +5127,12 @@ static void mpi3mr_remove(struct pci_dev *pdev)
        }
        spin_unlock_irqrestore(&mrioc->sas_node_lock, flags);
 
+       if (mrioc->sas_hba.num_phys) {
+               kfree(mrioc->sas_hba.phy);
+               mrioc->sas_hba.phy = NULL;
+               mrioc->sas_hba.num_phys = 0;
+       }
+
        spin_lock(&mrioc_list_lock);
        list_del(&mrioc->list);
        spin_unlock(&mrioc_list_lock);