[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250923152340.18234-5-johan@kernel.org>
Date: Tue, 23 Sep 2025 17:23:39 +0200
From: Johan Hovold <johan@...nel.org>
To: Chun-Kuang Hu <chunkuang.hu@...nel.org>,
Philipp Zabel <p.zabel@...gutronix.de>
Cc: David Airlie <airlied@...il.com>,
Simona Vetter <simona@...ll.ch>,
Matthias Brugger <matthias.bgg@...il.com>,
AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>,
dri-devel@...ts.freedesktop.org,
linux-mediatek@...ts.infradead.org,
linux-kernel@...r.kernel.org,
Johan Hovold <johan@...nel.org>,
stable@...r.kernel.org,
Jie Qiu <jie.qiu@...iatek.com>
Subject: [PATCH 4/5] drm/mediatek: mtk_hdmi: fix probe device leaks
Make sure to drop the references to the DDC adapter and CEC device
taken during probe on probe failure (e.g. probe deferral) and on driver
unbind.
Fixes: 8f83f26891e1 ("drm/mediatek: Add HDMI support")
Cc: stable@...r.kernel.org # 4.8
Cc: Jie Qiu <jie.qiu@...iatek.com>
Signed-off-by: Johan Hovold <johan@...nel.org>
---
drivers/gpu/drm/mediatek/mtk_hdmi.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c
index b766dd5e6c8d..306e2c907311 100644
--- a/drivers/gpu/drm/mediatek/mtk_hdmi.c
+++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c
@@ -1345,6 +1345,13 @@ static const struct drm_bridge_funcs mtk_hdmi_bridge_funcs = {
.edid_read = mtk_hdmi_bridge_edid_read,
};
+static void mtk_hdmi_put_device(void *_dev)
+{
+ struct device *dev = _dev;
+
+ put_device(dev);
+}
+
static int mtk_hdmi_get_cec_dev(struct mtk_hdmi *hdmi, struct device *dev, struct device_node *np)
{
struct platform_device *cec_pdev;
@@ -1369,6 +1376,10 @@ static int mtk_hdmi_get_cec_dev(struct mtk_hdmi *hdmi, struct device *dev, struc
}
of_node_put(cec_np);
+ ret = devm_add_action_or_reset(dev, mtk_hdmi_put_device, &cec_pdev->dev);
+ if (ret)
+ return ret;
+
/*
* The mediatek,syscon-hdmi property contains a phandle link to the
* MMSYS_CONFIG device and the register offset of the HDMI_SYS_CFG
@@ -1423,6 +1434,10 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi,
if (!hdmi->ddc_adpt)
return dev_err_probe(dev, -EINVAL, "Failed to get ddc i2c adapter by node\n");
+ ret = devm_add_action_or_reset(dev, mtk_hdmi_put_device, &hdmi->ddc_adpt->dev);
+ if (ret)
+ return ret;
+
ret = mtk_hdmi_get_cec_dev(hdmi, dev, np);
if (ret)
return ret;
--
2.49.1
Powered by blists - more mailing lists