Skip to content

Commit 2a07eab

Browse files
vmordangregkh
authored andcommitted
gpu: cdns-mhdp8546: fix call balance of mhdp->clk handling routines
[ Upstream commit f65727b ] If the clock mhdp->clk was not enabled in cdns_mhdp_probe(), it should not be disabled in any path. The return value of clk_prepare_enable() is not checked. If mhdp->clk was not enabled, it may be disabled in the error path of cdns_mhdp_probe() (e.g., if cdns_mhdp_load_firmware() fails) or in cdns_mhdp_remove() after a successful cdns_mhdp_probe() call. Use the devm_clk_get_enabled() helper function to ensure proper call balance for mhdp->clk. Found by Linux Verification Center (linuxtesting.org) with Klever. Fixes: fb43aa0 ("drm: bridge: Add support for Cadence MHDP8546 DPI/DP bridge") Signed-off-by: Vitalii Mordan <mordan@ispras.ru> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Signed-off-by: Robert Foss <rfoss@kernel.org> Link: https://patchwork.freedesktop.org/patch/msgid/20250214154632.1907425-1-mordan@ispras.ru Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent d5eb8e3 commit 2a07eab

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2463,9 +2463,9 @@ static int cdns_mhdp_probe(struct platform_device *pdev)
24632463
if (!mhdp)
24642464
return -ENOMEM;
24652465

2466-
clk = devm_clk_get(dev, NULL);
2466+
clk = devm_clk_get_enabled(dev, NULL);
24672467
if (IS_ERR(clk)) {
2468-
dev_err(dev, "couldn't get clk: %ld\n", PTR_ERR(clk));
2468+
dev_err(dev, "couldn't get and enable clk: %ld\n", PTR_ERR(clk));
24692469
return PTR_ERR(clk);
24702470
}
24712471

@@ -2504,14 +2504,12 @@ static int cdns_mhdp_probe(struct platform_device *pdev)
25042504

25052505
mhdp->info = of_device_get_match_data(dev);
25062506

2507-
clk_prepare_enable(clk);
2508-
25092507
pm_runtime_enable(dev);
25102508
ret = pm_runtime_resume_and_get(dev);
25112509
if (ret < 0) {
25122510
dev_err(dev, "pm_runtime_resume_and_get failed\n");
25132511
pm_runtime_disable(dev);
2514-
goto clk_disable;
2512+
return ret;
25152513
}
25162514

25172515
if (mhdp->info && mhdp->info->ops && mhdp->info->ops->init) {
@@ -2590,8 +2588,6 @@ static int cdns_mhdp_probe(struct platform_device *pdev)
25902588
runtime_put:
25912589
pm_runtime_put_sync(dev);
25922590
pm_runtime_disable(dev);
2593-
clk_disable:
2594-
clk_disable_unprepare(mhdp->clk);
25952591

25962592
return ret;
25972593
}
@@ -2632,8 +2628,6 @@ static void cdns_mhdp_remove(struct platform_device *pdev)
26322628
cancel_work_sync(&mhdp->modeset_retry_work);
26332629
flush_work(&mhdp->hpd_work);
26342630
/* Ignoring mhdp->hdcp.check_work and mhdp->hdcp.prop_work here. */
2635-
2636-
clk_disable_unprepare(mhdp->clk);
26372631
}
26382632

26392633
static const struct of_device_id mhdp_ids[] = {

0 commit comments

Comments
 (0)