Re: [PATCH v2] drm/mediatek: Add missing IS_ERR check for ovl_adaptor platform device

From: Chun-Kuang Hu

Date: Mon Sep 28 2026 - 19:29:07 EST


Haojie Li <lihaojie@xxxxxxxxxx> 於 2026年8月25日週二 下午6:09寫道:
>
> platform_device_register_data() can fail and return an ERR_PTR, but the
> return value is used without checking, leading to an invalid pointer
> being stored in ddp_comp[].dev and passed to component_match_add() and
> mtk_ddp_comp_init(), which could result in a kernel crash.
>
> Add an IS_ERR() check to jump to the error handling path on failure.

Applied to mediatek-drm-fixes [1], thanks.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/chunkuang.hu/linux.git/log/?h=mediatek-drm-fixes

Regards,
Chun-Kuang.

>
> Fixes: 0d9eee9118b7 ("drm/mediatek: Add drm ovl_adaptor sub driver for MT8195")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Haojie Li <lihaojie@xxxxxxxxxx>
> ---
> drivers/gpu/drm/mediatek/mtk_drm_drv.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> index c86a3f54f35b..b281482ab8c8 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> @@ -1112,6 +1112,9 @@ static int mtk_drm_probe(struct platform_device *pdev)
> PLATFORM_DEVID_AUTO,
> (void *)private->mmsys_dev,
> sizeof(*private->mmsys_dev));
> + if (IS_ERR(ovl_adaptor))
> + return PTR_ERR(ovl_adaptor);
> +
> private->ddp_comp[DDP_COMPONENT_DRM_OVL_ADAPTOR].dev = &ovl_adaptor->dev;
> mtk_ddp_comp_init(dev, NULL, &private->ddp_comp[DDP_COMPONENT_DRM_OVL_ADAPTOR],
> DDP_COMPONENT_DRM_OVL_ADAPTOR);
> --
> 2.25.1
>