drm/mediatek: Fix kobject put for component sub-drivers
authorAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Thu, 3 Apr 2025 10:47:38 +0000 (12:47 +0200)
committerChun-Kuang Hu <chunkuang.hu@kernel.org>
Wed, 14 May 2025 23:06:24 +0000 (23:06 +0000)
commit80805b62ea5b95eda54c225b989f929ca0691ab0
treeb0d0b86228791ce9ecda2881134fdf1e46ba1118
parent22918591fb747a6d16801e74a170cf98e886f83b
drm/mediatek: Fix kobject put for component sub-drivers

In function mtk_drm_get_all_drm_priv(), this driver is incrementing
the refcount for the sub-drivers of mediatek-drm with a call to
device_find_child() when taking a reference to all of those child
devices.

When the component bind fails multiple times this results in a
refcount_t overflow, as the reference count is never decremented:
fix that by adding a call to put_device() for all of the mmsys
devices in a loop, in error cases of mtk_drm_bind() and in the
mtk_drm_unbind() callback.

Fixes: 1ef7ed48356c ("drm/mediatek: Modify mediatek-drm for mt8195 multi mmsys support")
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://patchwork.kernel.org/project/dri-devel/patch/20250403104741.71045-3-angelogioacchino.delregno@collabora.com/
Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
drivers/gpu/drm/mediatek/mtk_drm_drv.c