Commit c3d4eb3b authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Thierry Reding

memory: tegra: Fix an error handling path in tegra186_emc_probe()

The call to tegra_bpmp_get() must be balanced by a call to
tegra_bpmp_put() in case of error, as already done in the remove
function.

Add an error handling path and corresponding goto.

Fixes: 52d15dd2 ("memory: tegra: Support DVFS on Tegra186 and later")
Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
parent 930c6818
...@@ -185,7 +185,7 @@ static int tegra186_emc_probe(struct platform_device *pdev) ...@@ -185,7 +185,7 @@ static int tegra186_emc_probe(struct platform_device *pdev)
if (IS_ERR(emc->clk)) { if (IS_ERR(emc->clk)) {
err = PTR_ERR(emc->clk); err = PTR_ERR(emc->clk);
dev_err(&pdev->dev, "failed to get EMC clock: %d\n", err); dev_err(&pdev->dev, "failed to get EMC clock: %d\n", err);
return err; goto put_bpmp;
} }
platform_set_drvdata(pdev, emc); platform_set_drvdata(pdev, emc);
...@@ -201,7 +201,7 @@ static int tegra186_emc_probe(struct platform_device *pdev) ...@@ -201,7 +201,7 @@ static int tegra186_emc_probe(struct platform_device *pdev)
err = tegra_bpmp_transfer(emc->bpmp, &msg); err = tegra_bpmp_transfer(emc->bpmp, &msg);
if (err < 0) { if (err < 0) {
dev_err(&pdev->dev, "failed to EMC DVFS pairs: %d\n", err); dev_err(&pdev->dev, "failed to EMC DVFS pairs: %d\n", err);
return err; goto put_bpmp;
} }
emc->debugfs.min_rate = ULONG_MAX; emc->debugfs.min_rate = ULONG_MAX;
...@@ -211,8 +211,10 @@ static int tegra186_emc_probe(struct platform_device *pdev) ...@@ -211,8 +211,10 @@ static int tegra186_emc_probe(struct platform_device *pdev)
emc->dvfs = devm_kmalloc_array(&pdev->dev, emc->num_dvfs, emc->dvfs = devm_kmalloc_array(&pdev->dev, emc->num_dvfs,
sizeof(*emc->dvfs), GFP_KERNEL); sizeof(*emc->dvfs), GFP_KERNEL);
if (!emc->dvfs) if (!emc->dvfs) {
return -ENOMEM; err = -ENOMEM;
goto put_bpmp;
}
dev_dbg(&pdev->dev, "%u DVFS pairs:\n", emc->num_dvfs); dev_dbg(&pdev->dev, "%u DVFS pairs:\n", emc->num_dvfs);
...@@ -237,7 +239,7 @@ static int tegra186_emc_probe(struct platform_device *pdev) ...@@ -237,7 +239,7 @@ static int tegra186_emc_probe(struct platform_device *pdev)
"failed to set rate range [%lu-%lu] for %pC\n", "failed to set rate range [%lu-%lu] for %pC\n",
emc->debugfs.min_rate, emc->debugfs.max_rate, emc->debugfs.min_rate, emc->debugfs.max_rate,
emc->clk); emc->clk);
return err; goto put_bpmp;
} }
emc->debugfs.root = debugfs_create_dir("emc", NULL); emc->debugfs.root = debugfs_create_dir("emc", NULL);
...@@ -254,6 +256,10 @@ static int tegra186_emc_probe(struct platform_device *pdev) ...@@ -254,6 +256,10 @@ static int tegra186_emc_probe(struct platform_device *pdev)
emc, &tegra186_emc_debug_max_rate_fops); emc, &tegra186_emc_debug_max_rate_fops);
return 0; return 0;
put_bpmp:
tegra_bpmp_put(emc->bpmp);
return err;
} }
static int tegra186_emc_remove(struct platform_device *pdev) static int tegra186_emc_remove(struct platform_device *pdev)
......
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