mtk_hdmi_get_all_clk() acquires clock references using
of_clk_get_by_name(), but these references are never released.
They leak when a later clock lookup or subsequent probe step
fails, as well as on driver unbind.

Use devm_clk_get() to automatically release each successfully acquired
clock reference on probe failure or driver unbind. Remove the now
unused device-node parameter from mtk_hdmi_get_all_clk() and update
its caller.

Fixes: 8f83f26891e1 ("drm/mediatek: Add HDMI support")
Signed-off-by: Haoxiang Li <[email protected]>
---
 drivers/gpu/drm/mediatek/mtk_hdmi_common.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi_common.c 
b/drivers/gpu/drm/mediatek/mtk_hdmi_common.c
index a36d8dd6b761..8e8ea4111351 100644
--- a/drivers/gpu/drm/mediatek/mtk_hdmi_common.c
+++ b/drivers/gpu/drm/mediatek/mtk_hdmi_common.c
@@ -199,13 +199,13 @@ void mtk_hdmi_audio_set_plugged_cb(struct mtk_hdmi *hdmi, 
hdmi_codec_plugged_cb
 }
 EXPORT_SYMBOL_NS_GPL(mtk_hdmi_audio_set_plugged_cb, "DRM_MTK_HDMI");
 
-static int mtk_hdmi_get_all_clk(struct mtk_hdmi *hdmi, struct device_node *np,
+static int mtk_hdmi_get_all_clk(struct mtk_hdmi *hdmi,
                                const char * const *clock_names, size_t 
num_clocks)
 {
        int i;
 
        for (i = 0; i < num_clocks; i++) {
-               hdmi->clk[i] = of_clk_get_by_name(np, clock_names[i]);
+               hdmi->clk[i] = devm_clk_get(hdmi->dev, clock_names[i]);
 
                if (IS_ERR(hdmi->clk[i]))
                        return PTR_ERR(hdmi->clk[i]);
@@ -305,7 +305,7 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi, 
struct platform_device
        struct device_node *remote, *i2c_np;
        int ret;
 
-       ret = mtk_hdmi_get_all_clk(hdmi, np, clk_names, num_clocks);
+       ret = mtk_hdmi_get_all_clk(hdmi, clk_names, num_clocks);
        if (ret)
                return dev_err_probe(dev, ret, "Failed to get clocks\n");
 
-- 
2.25.1

Reply via email to