Commit d0f3c372 authored by Tomas Henzl's avatar Tomas Henzl Committed by Martin K. Petersen

scsi: mpi3mr: Fix mpi3mr_hba_port memory leak in mpi3mr_remove()

Free mpi3mr_hba_port at .remove.

Fixes: 42fc9fee ("scsi: mpi3mr: Add helper functions to manage device's port")
Signed-off-by: default avatarTomas Henzl <thenzl@redhat.com>
Link: https://lore.kernel.org/r/20230302234336.25456-4-thenzl@redhat.comAcked-by: default avatarSathya Prakash Veerichetty <sathya.prakash@broadcom.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 7d2b0217
...@@ -5078,6 +5078,7 @@ static void mpi3mr_remove(struct pci_dev *pdev) ...@@ -5078,6 +5078,7 @@ static void mpi3mr_remove(struct pci_dev *pdev)
struct workqueue_struct *wq; struct workqueue_struct *wq;
unsigned long flags; unsigned long flags;
struct mpi3mr_tgt_dev *tgtdev, *tgtdev_next; struct mpi3mr_tgt_dev *tgtdev, *tgtdev_next;
struct mpi3mr_hba_port *port, *hba_port_next;
if (!shost) if (!shost)
return; return;
...@@ -5117,6 +5118,16 @@ static void mpi3mr_remove(struct pci_dev *pdev) ...@@ -5117,6 +5118,16 @@ static void mpi3mr_remove(struct pci_dev *pdev)
mpi3mr_free_mem(mrioc); mpi3mr_free_mem(mrioc);
mpi3mr_cleanup_resources(mrioc); mpi3mr_cleanup_resources(mrioc);
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",
port, port->port_id);
list_del(&port->list);
kfree(port);
}
spin_unlock_irqrestore(&mrioc->sas_node_lock, flags);
spin_lock(&mrioc_list_lock); spin_lock(&mrioc_list_lock);
list_del(&mrioc->list); list_del(&mrioc->list);
spin_unlock(&mrioc_list_lock); spin_unlock(&mrioc_list_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment