Commit 51e6ed83 authored by Ajish Koshy's avatar Ajish Koshy Committed by Martin K. Petersen

scsi: pm80xx: Fix memory leak during rmmod

Driver failed to release all memory allocated. This would lead to memory
leak during driver removal.

Properly free memory when the module is removed.

Link: https://lore.kernel.org/r/20210906170404.5682-5-Ajish.Koshy@microchip.comAcked-by: default avatarJack Wang <jinpu.wang@ionos.com>
Signed-off-by: default avatarAjish Koshy <Ajish.Koshy@microchip.com>
Signed-off-by: default avatarViswas G <Viswas.G@microchip.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent c29737d0
...@@ -1199,6 +1199,7 @@ pm8001_init_ccb_tag(struct pm8001_hba_info *pm8001_ha, struct Scsi_Host *shost, ...@@ -1199,6 +1199,7 @@ pm8001_init_ccb_tag(struct pm8001_hba_info *pm8001_ha, struct Scsi_Host *shost,
goto err_out; goto err_out;
/* Memory region for ccb_info*/ /* Memory region for ccb_info*/
pm8001_ha->ccb_count = ccb_count;
pm8001_ha->ccb_info = pm8001_ha->ccb_info =
kcalloc(ccb_count, sizeof(struct pm8001_ccb_info), GFP_KERNEL); kcalloc(ccb_count, sizeof(struct pm8001_ccb_info), GFP_KERNEL);
if (!pm8001_ha->ccb_info) { if (!pm8001_ha->ccb_info) {
...@@ -1260,6 +1261,16 @@ static void pm8001_pci_remove(struct pci_dev *pdev) ...@@ -1260,6 +1261,16 @@ static void pm8001_pci_remove(struct pci_dev *pdev)
tasklet_kill(&pm8001_ha->tasklet[j]); tasklet_kill(&pm8001_ha->tasklet[j]);
#endif #endif
scsi_host_put(pm8001_ha->shost); scsi_host_put(pm8001_ha->shost);
for (i = 0; i < pm8001_ha->ccb_count; i++) {
dma_free_coherent(&pm8001_ha->pdev->dev,
sizeof(struct pm8001_prd) * PM8001_MAX_DMA_SG,
pm8001_ha->ccb_info[i].buf_prd,
pm8001_ha->ccb_info[i].ccb_dma_handle);
}
kfree(pm8001_ha->ccb_info);
kfree(pm8001_ha->devices);
pm8001_free(pm8001_ha); pm8001_free(pm8001_ha);
kfree(sha->sas_phy); kfree(sha->sas_phy);
kfree(sha->sas_port); kfree(sha->sas_port);
......
...@@ -518,6 +518,7 @@ struct pm8001_hba_info { ...@@ -518,6 +518,7 @@ struct pm8001_hba_info {
u32 iomb_size; /* SPC and SPCV IOMB size */ u32 iomb_size; /* SPC and SPCV IOMB size */
struct pm8001_device *devices; struct pm8001_device *devices;
struct pm8001_ccb_info *ccb_info; struct pm8001_ccb_info *ccb_info;
u32 ccb_count;
#ifdef PM8001_USE_MSIX #ifdef PM8001_USE_MSIX
int number_of_intr;/*will be used in remove()*/ int number_of_intr;/*will be used in remove()*/
char intr_drvname[PM8001_MAX_MSIX_VEC] char intr_drvname[PM8001_MAX_MSIX_VEC]
......
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