Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/mediatek: ovl_adaptor: Fix probe device leaks

Make sure to drop the references taken to the component devices by
of_find_device_by_node() during probe on probe failure (e.g. probe
deferral) and on driver unbind.

Fixes: 453c3364632a ("drm/mediatek: Add ovl_adaptor support for MT8195")
Cc: stable@vger.kernel.org # 6.4
Cc: Nancy.Lin <nancy.lin@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-6-johan@kernel.org/
Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>

authored by

Johan Hovold and committed by
Chun-Kuang Hu
e0f44f74 2a2a04be

+12
+12
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c
··· 527 527 type == OVL_ADAPTOR_TYPE_PADDING; 528 528 } 529 529 530 + static void ovl_adaptor_put_device(void *_dev) 531 + { 532 + struct device *dev = _dev; 533 + 534 + put_device(dev); 535 + } 536 + 530 537 static int ovl_adaptor_comp_init(struct device *dev, struct component_match **match) 531 538 { 532 539 struct mtk_disp_ovl_adaptor *priv = dev_get_drvdata(dev); ··· 566 559 comp_pdev = of_find_device_by_node(node); 567 560 if (!comp_pdev) 568 561 return -EPROBE_DEFER; 562 + 563 + ret = devm_add_action_or_reset(dev, ovl_adaptor_put_device, 564 + &comp_pdev->dev); 565 + if (ret) 566 + return ret; 569 567 570 568 priv->ovl_adaptor_comp[id] = &comp_pdev->dev; 571 569