[PATCH -next] drm: xlnx: zynqmp_dpsub: fix missing clk_disable_unprepare() in error path in zynqmp_dpsub_init_clocks()

Yang Yingliang yangyingliang at huawei.com
Sat Oct 29 03:15:00 UTC 2022


If get video or audio clock failed, it should call clk_disable_unprepare()
in error path.

Fixes: c979296ef60c ("drm: xlnx: zynqmp_dpsub: Move audio clk from zynqmp_disp to zynqmp_dpsub")
Fixes: 1682ade66308 ("drm: xlnx: zynqmp_dpsub: Move pclk from zynqmp_disp to zynqmp_dpsub")
Signed-off-by: Yang Yingliang <yangyingliang at huawei.com>
---
 drivers/gpu/drm/xlnx/zynqmp_dpsub.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/xlnx/zynqmp_dpsub.c b/drivers/gpu/drm/xlnx/zynqmp_dpsub.c
index bab862484d42..50abe222fcc3 100644
--- a/drivers/gpu/drm/xlnx/zynqmp_dpsub.c
+++ b/drivers/gpu/drm/xlnx/zynqmp_dpsub.c
@@ -109,16 +109,19 @@ static int zynqmp_dpsub_init_clocks(struct zynqmp_dpsub *dpsub)
 	 * live PL video clock isn't valid.
 	 */
 	dpsub->vid_clk = devm_clk_get(dpsub->dev, "dp_live_video_in_clk");
-	if (!IS_ERR(dpsub->vid_clk))
+	if (!IS_ERR(dpsub->vid_clk)) {
 		dpsub->vid_clk_from_ps = false;
-	else if (PTR_ERR(dpsub->vid_clk) == -EPROBE_DEFER)
-		return PTR_ERR(dpsub->vid_clk);
+	} else if (PTR_ERR(dpsub->vid_clk) == -EPROBE_DEFER) {
+		ret = PTR_ERR(dpsub->vid_clk);
+		goto err_disable_clk;
+	}
 
 	if (IS_ERR_OR_NULL(dpsub->vid_clk)) {
 		dpsub->vid_clk = devm_clk_get(dpsub->dev, "dp_vtc_pixel_clk_in");
 		if (IS_ERR(dpsub->vid_clk)) {
 			dev_err(dpsub->dev, "failed to init any video clock\n");
-			return PTR_ERR(dpsub->vid_clk);
+			ret = PTR_ERR(dpsub->vid_clk);
+			goto err_disable_clk;
 		}
 		dpsub->vid_clk_from_ps = true;
 	}
@@ -142,6 +145,11 @@ static int zynqmp_dpsub_init_clocks(struct zynqmp_dpsub *dpsub)
 
 	dev_info(dpsub->dev, "audio disabled due to missing clock\n");
 	return 0;
+
+err_disable_clk:
+	clk_disable_unprepare(dpsub->apb_clk);
+
+	return ret;
 }
 
 static int zynqmp_dpsub_parse_dt(struct zynqmp_dpsub *dpsub)
-- 
2.25.1



More information about the dri-devel mailing list