Commit 76aae5f6 authored by John Garry's avatar John Garry Committed by Martin K. Petersen

scsi: hisi_sas: replace kfree with scsi_host_put

Instances of kfree(shost) should be replaced with scsi_host_put().

In addition, a missing scsi_host_put() is added for error path in
hisi_sas_shost_alloc_pci() and v3 driver removal.

Signed-off-by: Pan Bian <bianpan2016@163.com> # For main.c changes
Signed-off-by: default avatarJohn Garry <john.garry@huawei.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 5aec704f
...@@ -1900,7 +1900,7 @@ static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev, ...@@ -1900,7 +1900,7 @@ static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev,
return shost; return shost;
err_out: err_out:
kfree(shost); scsi_host_put(shost);
dev_err(dev, "shost alloc failed\n"); dev_err(dev, "shost alloc failed\n");
return NULL; return NULL;
} }
...@@ -1991,7 +1991,7 @@ int hisi_sas_probe(struct platform_device *pdev, ...@@ -1991,7 +1991,7 @@ int hisi_sas_probe(struct platform_device *pdev,
scsi_remove_host(shost); scsi_remove_host(shost);
err_out_ha: err_out_ha:
hisi_sas_free(hisi_hba); hisi_sas_free(hisi_hba);
kfree(shost); scsi_host_put(shost);
return rc; return rc;
} }
EXPORT_SYMBOL_GPL(hisi_sas_probe); EXPORT_SYMBOL_GPL(hisi_sas_probe);
...@@ -2006,7 +2006,7 @@ int hisi_sas_remove(struct platform_device *pdev) ...@@ -2006,7 +2006,7 @@ int hisi_sas_remove(struct platform_device *pdev)
sas_remove_host(sha->core.shost); sas_remove_host(sha->core.shost);
hisi_sas_free(hisi_hba); hisi_sas_free(hisi_hba);
kfree(shost); scsi_host_put(shost);
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(hisi_sas_remove); EXPORT_SYMBOL_GPL(hisi_sas_remove);
......
...@@ -1811,8 +1811,10 @@ hisi_sas_shost_alloc_pci(struct pci_dev *pdev) ...@@ -1811,8 +1811,10 @@ hisi_sas_shost_alloc_pci(struct pci_dev *pdev)
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
shost = scsi_host_alloc(hisi_sas_sht, sizeof(*hisi_hba)); shost = scsi_host_alloc(hisi_sas_sht, sizeof(*hisi_hba));
if (!shost) if (!shost) {
goto err_out; dev_err(dev, "shost alloc failed\n");
return NULL;
}
hisi_hba = shost_priv(shost); hisi_hba = shost_priv(shost);
hisi_hba->hw = &hisi_sas_v3_hw; hisi_hba->hw = &hisi_sas_v3_hw;
...@@ -1833,6 +1835,7 @@ hisi_sas_shost_alloc_pci(struct pci_dev *pdev) ...@@ -1833,6 +1835,7 @@ hisi_sas_shost_alloc_pci(struct pci_dev *pdev)
return shost; return shost;
err_out: err_out:
scsi_host_put(shost);
dev_err(dev, "shost alloc failed\n"); dev_err(dev, "shost alloc failed\n");
return NULL; return NULL;
} }
...@@ -1941,7 +1944,7 @@ hisi_sas_v3_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -1941,7 +1944,7 @@ hisi_sas_v3_probe(struct pci_dev *pdev, const struct pci_device_id *id)
err_out_register_ha: err_out_register_ha:
scsi_remove_host(shost); scsi_remove_host(shost);
err_out_ha: err_out_ha:
kfree(shost); scsi_host_put(shost);
err_out_regions: err_out_regions:
pci_release_regions(pdev); pci_release_regions(pdev);
err_out_disable_device: err_out_disable_device:
...@@ -1971,14 +1974,16 @@ static void hisi_sas_v3_remove(struct pci_dev *pdev) ...@@ -1971,14 +1974,16 @@ static void hisi_sas_v3_remove(struct pci_dev *pdev)
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct sas_ha_struct *sha = dev_get_drvdata(dev); struct sas_ha_struct *sha = dev_get_drvdata(dev);
struct hisi_hba *hisi_hba = sha->lldd_ha; struct hisi_hba *hisi_hba = sha->lldd_ha;
struct Scsi_Host *shost = sha->core.shost;
sas_unregister_ha(sha); sas_unregister_ha(sha);
sas_remove_host(sha->core.shost); sas_remove_host(sha->core.shost);
hisi_sas_free(hisi_hba);
hisi_sas_v3_destroy_irqs(pdev, hisi_hba); hisi_sas_v3_destroy_irqs(pdev, hisi_hba);
pci_release_regions(pdev); pci_release_regions(pdev);
pci_disable_device(pdev); pci_disable_device(pdev);
hisi_sas_free(hisi_hba);
scsi_host_put(shost);
} }
enum { enum {
......
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