Skip to content

Commit ce756da

Browse files
thenzlmartinkpetersen
authored andcommitted
scsi: mpi3mr: Fix expander node leak in mpi3mr_remove()
Add a missing resource clean up in .remove. Fixes: e22bae3 ("scsi: mpi3mr: Add expander devices to STL") Signed-off-by: Tomas Henzl <[email protected]> Link: https://lore.kernel.org/r/[email protected] Acked-by: Sathya Prakash Veerichetty <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent c798304 commit ce756da

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

drivers/scsi/mpi3mr/mpi3mr.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,4 +1393,6 @@ void mpi3mr_flush_drv_cmds(struct mpi3mr_ioc *mrioc);
13931393
void mpi3mr_flush_cmds_for_unrecovered_controller(struct mpi3mr_ioc *mrioc);
13941394
void mpi3mr_free_enclosure_list(struct mpi3mr_ioc *mrioc);
13951395
int mpi3mr_process_admin_reply_q(struct mpi3mr_ioc *mrioc);
1396+
void mpi3mr_expander_node_remove(struct mpi3mr_ioc *mrioc,
1397+
struct mpi3mr_sas_node *sas_expander);
13961398
#endif /*MPI3MR_H_INCLUDED*/

drivers/scsi/mpi3mr/mpi3mr_os.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5079,6 +5079,7 @@ static void mpi3mr_remove(struct pci_dev *pdev)
50795079
unsigned long flags;
50805080
struct mpi3mr_tgt_dev *tgtdev, *tgtdev_next;
50815081
struct mpi3mr_hba_port *port, *hba_port_next;
5082+
struct mpi3mr_sas_node *sas_expander, *sas_expander_next;
50825083

50835084
if (!shost)
50845085
return;
@@ -5119,6 +5120,12 @@ static void mpi3mr_remove(struct pci_dev *pdev)
51195120
mpi3mr_cleanup_resources(mrioc);
51205121

51215122
spin_lock_irqsave(&mrioc->sas_node_lock, flags);
5123+
list_for_each_entry_safe_reverse(sas_expander, sas_expander_next,
5124+
&mrioc->sas_expander_list, list) {
5125+
spin_unlock_irqrestore(&mrioc->sas_node_lock, flags);
5126+
mpi3mr_expander_node_remove(mrioc, sas_expander);
5127+
spin_lock_irqsave(&mrioc->sas_node_lock, flags);
5128+
}
51225129
list_for_each_entry_safe(port, hba_port_next, &mrioc->hba_port_table_list, list) {
51235130
ioc_info(mrioc,
51245131
"removing hba_port entry: %p port: %d from hba_port list\n",

drivers/scsi/mpi3mr/mpi3mr_transport.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99

1010
#include "mpi3mr.h"
1111

12-
static void mpi3mr_expander_node_remove(struct mpi3mr_ioc *mrioc,
13-
struct mpi3mr_sas_node *sas_expander);
14-
1512
/**
1613
* mpi3mr_post_transport_req - Issue transport requests and wait
1714
* @mrioc: Adapter instance reference
@@ -2164,7 +2161,7 @@ int mpi3mr_expander_add(struct mpi3mr_ioc *mrioc, u16 handle)
21642161
*
21652162
* Return nothing.
21662163
*/
2167-
static void mpi3mr_expander_node_remove(struct mpi3mr_ioc *mrioc,
2164+
void mpi3mr_expander_node_remove(struct mpi3mr_ioc *mrioc,
21682165
struct mpi3mr_sas_node *sas_expander)
21692166
{
21702167
struct mpi3mr_sas_port *mr_sas_port, *next;

0 commit comments

Comments
 (0)