Skip to content

Commit c3d4eb3

Browse files
tititiou36thierryreding
authored andcommitted
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: 52d15dd ("memory: tegra: Support DVFS on Tegra186 and later") Signed-off-by: Christophe JAILLET <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent 930c681 commit c3d4eb3

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

drivers/memory/tegra/tegra186-emc.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ static int tegra186_emc_probe(struct platform_device *pdev)
185185
if (IS_ERR(emc->clk)) {
186186
err = PTR_ERR(emc->clk);
187187
dev_err(&pdev->dev, "failed to get EMC clock: %d\n", err);
188-
return err;
188+
goto put_bpmp;
189189
}
190190

191191
platform_set_drvdata(pdev, emc);
@@ -201,7 +201,7 @@ static int tegra186_emc_probe(struct platform_device *pdev)
201201
err = tegra_bpmp_transfer(emc->bpmp, &msg);
202202
if (err < 0) {
203203
dev_err(&pdev->dev, "failed to EMC DVFS pairs: %d\n", err);
204-
return err;
204+
goto put_bpmp;
205205
}
206206

207207
emc->debugfs.min_rate = ULONG_MAX;
@@ -211,8 +211,10 @@ static int tegra186_emc_probe(struct platform_device *pdev)
211211

212212
emc->dvfs = devm_kmalloc_array(&pdev->dev, emc->num_dvfs,
213213
sizeof(*emc->dvfs), GFP_KERNEL);
214-
if (!emc->dvfs)
215-
return -ENOMEM;
214+
if (!emc->dvfs) {
215+
err = -ENOMEM;
216+
goto put_bpmp;
217+
}
216218

217219
dev_dbg(&pdev->dev, "%u DVFS pairs:\n", emc->num_dvfs);
218220

@@ -237,7 +239,7 @@ static int tegra186_emc_probe(struct platform_device *pdev)
237239
"failed to set rate range [%lu-%lu] for %pC\n",
238240
emc->debugfs.min_rate, emc->debugfs.max_rate,
239241
emc->clk);
240-
return err;
242+
goto put_bpmp;
241243
}
242244

243245
emc->debugfs.root = debugfs_create_dir("emc", NULL);
@@ -254,6 +256,10 @@ static int tegra186_emc_probe(struct platform_device *pdev)
254256
emc, &tegra186_emc_debug_max_rate_fops);
255257

256258
return 0;
259+
260+
put_bpmp:
261+
tegra_bpmp_put(emc->bpmp);
262+
return err;
257263
}
258264

259265
static int tegra186_emc_remove(struct platform_device *pdev)

0 commit comments

Comments
 (0)