Skip to content

Commit b3e9222

Browse files
jhovoldgregkh
authored andcommitted
drm/mediatek: mtk_hdmi: Fix probe device leaks
commit 9545bae upstream. 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: 8f83f26 ("drm/mediatek: Add HDMI support") Cc: stable@vger.kernel.org # 4.8 Cc: Jie Qiu <jie.qiu@mediatek.com> Signed-off-by: Johan Hovold <johan@kernel.org> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Link: https://patchwork.kernel.org/project/dri-devel/patch/20250923152340.18234-5-johan@kernel.org/ Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 8f05959 commit b3e9222

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

drivers/gpu/drm/mediatek/mtk_hdmi.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,6 +1345,13 @@ static const struct drm_bridge_funcs mtk_hdmi_bridge_funcs = {
13451345
.edid_read = mtk_hdmi_bridge_edid_read,
13461346
};
13471347

1348+
static void mtk_hdmi_put_device(void *_dev)
1349+
{
1350+
struct device *dev = _dev;
1351+
1352+
put_device(dev);
1353+
}
1354+
13481355
static int mtk_hdmi_get_cec_dev(struct mtk_hdmi *hdmi, struct device *dev, struct device_node *np)
13491356
{
13501357
struct platform_device *cec_pdev;
@@ -1369,6 +1376,10 @@ static int mtk_hdmi_get_cec_dev(struct mtk_hdmi *hdmi, struct device *dev, struc
13691376
}
13701377
of_node_put(cec_np);
13711378

1379+
ret = devm_add_action_or_reset(dev, mtk_hdmi_put_device, &cec_pdev->dev);
1380+
if (ret)
1381+
return ret;
1382+
13721383
/*
13731384
* The mediatek,syscon-hdmi property contains a phandle link to the
13741385
* 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,
14231434
if (!hdmi->ddc_adpt)
14241435
return dev_err_probe(dev, -EINVAL, "Failed to get ddc i2c adapter by node\n");
14251436

1437+
ret = devm_add_action_or_reset(dev, mtk_hdmi_put_device, &hdmi->ddc_adpt->dev);
1438+
if (ret)
1439+
return ret;
1440+
14261441
ret = mtk_hdmi_get_cec_dev(hdmi, dev, np);
14271442
if (ret)
14281443
return ret;

0 commit comments

Comments
 (0)