Commit b9c2fab1 authored by Subhash Jadavani's avatar Subhash Jadavani Committed by Kleber Sacilotto de Souza

scsi: ufshcd: release resources if probe fails

BugLink: https://bugs.launchpad.net/bugs/1810967

commit afa3dfd4 upstream.

If ufshcd pltfrm/pci driver's probe fails for some reason then ensure
that scsi host is released to avoid memory leak but managed memory
allocations (via devm_* calls) need not to be freed explicitly on probe
failure as memory allocated with these functions is automatically freed
on driver detach.
Reviewed-by: default avatarSahitya Tummala <stummala@codeaurora.org>
Signed-off-by: default avatarSubhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: default avatarAmit Pundir <amit.pundir@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarJuerg Haefliger <juergh@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent 3777236c
...@@ -104,6 +104,7 @@ static void ufshcd_pci_remove(struct pci_dev *pdev) ...@@ -104,6 +104,7 @@ static void ufshcd_pci_remove(struct pci_dev *pdev)
pm_runtime_forbid(&pdev->dev); pm_runtime_forbid(&pdev->dev);
pm_runtime_get_noresume(&pdev->dev); pm_runtime_get_noresume(&pdev->dev);
ufshcd_remove(hba); ufshcd_remove(hba);
ufshcd_dealloc_host(hba);
} }
/** /**
...@@ -147,6 +148,7 @@ ufshcd_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -147,6 +148,7 @@ ufshcd_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
err = ufshcd_init(hba, mmio_base, pdev->irq); err = ufshcd_init(hba, mmio_base, pdev->irq);
if (err) { if (err) {
dev_err(&pdev->dev, "Initialization failed\n"); dev_err(&pdev->dev, "Initialization failed\n");
ufshcd_dealloc_host(hba);
return err; return err;
} }
......
...@@ -161,7 +161,7 @@ static int ufshcd_populate_vreg(struct device *dev, const char *name, ...@@ -161,7 +161,7 @@ static int ufshcd_populate_vreg(struct device *dev, const char *name,
if (ret) { if (ret) {
dev_err(dev, "%s: unable to find %s err %d\n", dev_err(dev, "%s: unable to find %s err %d\n",
__func__, prop_name, ret); __func__, prop_name, ret);
goto out_free; goto out;
} }
vreg->min_uA = 0; vreg->min_uA = 0;
...@@ -183,9 +183,6 @@ static int ufshcd_populate_vreg(struct device *dev, const char *name, ...@@ -183,9 +183,6 @@ static int ufshcd_populate_vreg(struct device *dev, const char *name,
goto out; goto out;
out_free:
devm_kfree(dev, vreg);
vreg = NULL;
out: out:
if (!ret) if (!ret)
*out_vreg = vreg; *out_vreg = vreg;
......
...@@ -5385,8 +5385,6 @@ void ufshcd_remove(struct ufs_hba *hba) ...@@ -5385,8 +5385,6 @@ void ufshcd_remove(struct ufs_hba *hba)
ufshcd_disable_intr(hba, hba->intr_mask); ufshcd_disable_intr(hba, hba->intr_mask);
ufshcd_hba_stop(hba); ufshcd_hba_stop(hba);
scsi_host_put(hba->host);
ufshcd_exit_clk_gating(hba); ufshcd_exit_clk_gating(hba);
if (ufshcd_is_clkscaling_enabled(hba)) if (ufshcd_is_clkscaling_enabled(hba))
devfreq_remove_device(hba->devfreq); devfreq_remove_device(hba->devfreq);
...@@ -5733,7 +5731,6 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) ...@@ -5733,7 +5731,6 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
ufshcd_exit_clk_gating(hba); ufshcd_exit_clk_gating(hba);
out_disable: out_disable:
hba->is_irq_enabled = false; hba->is_irq_enabled = false;
scsi_host_put(host);
ufshcd_hba_exit(hba); ufshcd_hba_exit(hba);
out_error: out_error:
return err; return err;
......
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