diff options
author | Pan Bian <bianpan2016@163.com> | 2017-08-08 07:40:30 -0400 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2017-08-10 19:55:35 -0400 |
commit | bc1371c181b503fe925ae292cd96618f305790cd (patch) | |
tree | 5992e86ed76195b4ff9e05afa92e9960c5a1f4fa /drivers/scsi/pm8001/pm8001_init.c | |
parent | 3b8328e2e0fda49202b502154608dd6fb8e8ed37 (diff) |
scsi: pm8001: fix double free in pm8001_pci_probe
In function pm8001_pci_probe(), on errors that the control flow jumps to
label err_out_ha_free, function pm8001_free() is called. In pm8001_free(),
scsi_host_put() is called to release shost, which keeps the return value
of scsi_host_alloc(). After pm8001_free() returns, kfree() is called to
free shost again, resulting in a double free bug. This patch removes
scsi_host_put() from pm8001_free() and explicitly calls scsi_host_put()
to release Scsi_Host in need.
Signed-off-by: Pan Bian <bianpan2016@163.com>
Reviewed-by: Jack Wang <jinpu.wang@profitbricks.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/pm8001/pm8001_init.c')
-rw-r--r-- | drivers/scsi/pm8001/pm8001_init.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c index 034b2f7d1135..2908881bad51 100644 --- a/drivers/scsi/pm8001/pm8001_init.c +++ b/drivers/scsi/pm8001/pm8001_init.c | |||
@@ -160,8 +160,6 @@ static void pm8001_free(struct pm8001_hba_info *pm8001_ha) | |||
160 | } | 160 | } |
161 | } | 161 | } |
162 | PM8001_CHIP_DISP->chip_iounmap(pm8001_ha); | 162 | PM8001_CHIP_DISP->chip_iounmap(pm8001_ha); |
163 | if (pm8001_ha->shost) | ||
164 | scsi_host_put(pm8001_ha->shost); | ||
165 | flush_workqueue(pm8001_wq); | 163 | flush_workqueue(pm8001_wq); |
166 | kfree(pm8001_ha->tags); | 164 | kfree(pm8001_ha->tags); |
167 | kfree(pm8001_ha); | 165 | kfree(pm8001_ha); |
@@ -1073,7 +1071,7 @@ err_out_ha_free: | |||
1073 | err_out_free: | 1071 | err_out_free: |
1074 | kfree(SHOST_TO_SAS_HA(shost)); | 1072 | kfree(SHOST_TO_SAS_HA(shost)); |
1075 | err_out_free_host: | 1073 | err_out_free_host: |
1076 | kfree(shost); | 1074 | scsi_host_put(shost); |
1077 | err_out_regions: | 1075 | err_out_regions: |
1078 | pci_release_regions(pdev); | 1076 | pci_release_regions(pdev); |
1079 | err_out_disable: | 1077 | err_out_disable: |
@@ -1112,6 +1110,7 @@ static void pm8001_pci_remove(struct pci_dev *pdev) | |||
1112 | for (j = 0; j < PM8001_MAX_MSIX_VEC; j++) | 1110 | for (j = 0; j < PM8001_MAX_MSIX_VEC; j++) |
1113 | tasklet_kill(&pm8001_ha->tasklet[j]); | 1111 | tasklet_kill(&pm8001_ha->tasklet[j]); |
1114 | #endif | 1112 | #endif |
1113 | scsi_host_put(pm8001_ha->shost); | ||
1115 | pm8001_free(pm8001_ha); | 1114 | pm8001_free(pm8001_ha); |
1116 | kfree(sha->sas_phy); | 1115 | kfree(sha->sas_phy); |
1117 | kfree(sha->sas_port); | 1116 | kfree(sha->sas_port); |