Skip to content

Commit 80805b6

Browse files
AngeloGioacchino Del RegnoChun-Kuang Hu
authored andcommitted
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: 1ef7ed4 ("drm/mediatek: Modify mediatek-drm for mt8195 multi mmsys support") Reviewed-by: Chen-Yu Tsai <[email protected]> Signed-off-by: AngeloGioacchino Del Regno <[email protected]> Link: https://patchwork.kernel.org/project/dri-devel/patch/[email protected]/ Signed-off-by: Chun-Kuang Hu <[email protected]>
1 parent 2291859 commit 80805b6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

drivers/gpu/drm/mediatek/mtk_drm_drv.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,20 +682,29 @@ static int mtk_drm_bind(struct device *dev)
682682
for (i = 0; i < private->data->mmsys_dev_num; i++)
683683
private->all_drm_private[i]->drm = NULL;
684684
err_put_dev:
685+
for (i = 0; i < private->data->mmsys_dev_num; i++) {
686+
/* For device_find_child in mtk_drm_get_all_priv() */
687+
put_device(private->all_drm_private[i]->dev);
688+
}
685689
put_device(private->mutex_dev);
686690
return ret;
687691
}
688692

689693
static void mtk_drm_unbind(struct device *dev)
690694
{
691695
struct mtk_drm_private *private = dev_get_drvdata(dev);
696+
int i;
692697

693698
/* for multi mmsys dev, unregister drm dev in mmsys master */
694699
if (private->drm_master) {
695700
drm_dev_unregister(private->drm);
696701
mtk_drm_kms_deinit(private->drm);
697702
drm_dev_put(private->drm);
698703

704+
for (i = 0; i < private->data->mmsys_dev_num; i++) {
705+
/* For device_find_child in mtk_drm_get_all_priv() */
706+
put_device(private->all_drm_private[i]->dev);
707+
}
699708
put_device(private->mutex_dev);
700709
}
701710
private->mtk_drm_bound = false;

0 commit comments

Comments
 (0)