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

Add a missing resource clean up in .remove.

Fixes: 38e56ff115e1 ("scsi: mpi3mr: Add expander devices to STL")
Signed-off-by: Tomas Henzl <thenzl@redhat.com>
Link: https://lore.kernel.org/r/20230302234336.25456-7-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.h
drivers/scsi/mpi3mr/mpi3mr_os.c
drivers/scsi/mpi3mr/mpi3mr_transport.c

index 68f29ffb05b828470a6948e48135dd61e8d18623..de6914d57402c855d45fe47d2c65fbd6894314a5 100644 (file)
@@ -1394,4 +1394,6 @@ void mpi3mr_flush_drv_cmds(struct mpi3mr_ioc *mrioc);
 void mpi3mr_flush_cmds_for_unrecovered_controller(struct mpi3mr_ioc *mrioc);
 void mpi3mr_free_enclosure_list(struct mpi3mr_ioc *mrioc);
 int mpi3mr_process_admin_reply_q(struct mpi3mr_ioc *mrioc);
+void mpi3mr_expander_node_remove(struct mpi3mr_ioc *mrioc,
+       struct mpi3mr_sas_node *sas_expander);
 #endif /*MPI3MR_H_INCLUDED*/
index 2e546c80d98ce638eb8657e1aa15e3f5a0b836ba..6d55698ea4d16c9ca22c6ca136e18ca7be2977d0 100644 (file)
@@ -5079,6 +5079,7 @@ static void mpi3mr_remove(struct pci_dev *pdev)
        unsigned long flags;
        struct mpi3mr_tgt_dev *tgtdev, *tgtdev_next;
        struct mpi3mr_hba_port *port, *hba_port_next;
+       struct mpi3mr_sas_node *sas_expander, *sas_expander_next;
 
        if (!shost)
                return;
@@ -5119,6 +5120,12 @@ static void mpi3mr_remove(struct pci_dev *pdev)
        mpi3mr_cleanup_resources(mrioc);
 
        spin_lock_irqsave(&mrioc->sas_node_lock, flags);
+       list_for_each_entry_safe_reverse(sas_expander, sas_expander_next,
+           &mrioc->sas_expander_list, list) {
+               spin_unlock_irqrestore(&mrioc->sas_node_lock, flags);
+               mpi3mr_expander_node_remove(mrioc, sas_expander);
+               spin_lock_irqsave(&mrioc->sas_node_lock, flags);
+       }
        list_for_each_entry_safe(port, hba_port_next, &mrioc->hba_port_table_list, list) {
                ioc_info(mrioc,
                    "removing hba_port entry: %p port: %d from hba_port list\n",
index 3b61815979dabe5c9a1113a410f34e3333905229..50263ba4f8428614bc19532e0528dc624a1c9fde 100644 (file)
@@ -9,9 +9,6 @@
 
 #include "mpi3mr.h"
 
-static void mpi3mr_expander_node_remove(struct mpi3mr_ioc *mrioc,
-       struct mpi3mr_sas_node *sas_expander);
-
 /**
  * mpi3mr_post_transport_req - Issue transport requests and wait
  * @mrioc: Adapter instance reference
@@ -2163,7 +2160,7 @@ out_fail:
  *
  * Return nothing.
  */
-static void mpi3mr_expander_node_remove(struct mpi3mr_ioc *mrioc,
+void mpi3mr_expander_node_remove(struct mpi3mr_ioc *mrioc,
        struct mpi3mr_sas_node *sas_expander)
 {
        struct mpi3mr_sas_port *mr_sas_port, *next;