Skip to content

Commit d0f3c37

Browse files
thenzlmartinkpetersen
authored andcommitted
scsi: mpi3mr: Fix mpi3mr_hba_port memory leak in mpi3mr_remove()
Free mpi3mr_hba_port at .remove. Fixes: 42fc9fe ("scsi: mpi3mr: Add helper functions to manage device's port") 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 7d2b021 commit d0f3c37

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

drivers/scsi/mpi3mr/mpi3mr_os.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5078,6 +5078,7 @@ static void mpi3mr_remove(struct pci_dev *pdev)
50785078
struct workqueue_struct *wq;
50795079
unsigned long flags;
50805080
struct mpi3mr_tgt_dev *tgtdev, *tgtdev_next;
5081+
struct mpi3mr_hba_port *port, *hba_port_next;
50815082

50825083
if (!shost)
50835084
return;
@@ -5117,6 +5118,16 @@ static void mpi3mr_remove(struct pci_dev *pdev)
51175118
mpi3mr_free_mem(mrioc);
51185119
mpi3mr_cleanup_resources(mrioc);
51195120

5121+
spin_lock_irqsave(&mrioc->sas_node_lock, flags);
5122+
list_for_each_entry_safe(port, hba_port_next, &mrioc->hba_port_table_list, list) {
5123+
ioc_info(mrioc,
5124+
"removing hba_port entry: %p port: %d from hba_port list\n",
5125+
port, port->port_id);
5126+
list_del(&port->list);
5127+
kfree(port);
5128+
}
5129+
spin_unlock_irqrestore(&mrioc->sas_node_lock, flags);
5130+
51205131
spin_lock(&mrioc_list_lock);
51215132
list_del(&mrioc->list);
51225133
spin_unlock(&mrioc_list_lock);

0 commit comments

Comments
 (0)