When the device is not the mmsys master, mtk_drm_bind() returns early
after taking a reference on the disp-mutex device via
of_find_device_by_node(), without ever dropping it: mtk_drm_unbind()
only puts mutex_dev for the master. Drop the reference before returning
from the non-master path.

Fixes: 1ef7ed48356c ("drm/mediatek: Modify mediatek-drm for mt8195 multi mmsys 
support")
Cc: [email protected]
Signed-off-by: Wentao Liang <[email protected]>
---
 drivers/gpu/drm/mediatek/mtk_drm_drv.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c 
b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
index c86a3f54f35b..e46f3ab2673f 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
@@ -638,8 +638,10 @@ static int mtk_drm_bind(struct device *dev)
        private->mtk_drm_bound = true;
        private->dev = dev;
 
-       if (!mtk_drm_get_all_drm_priv(dev))
+       if (!mtk_drm_get_all_drm_priv(dev)) {
+               put_device(private->mutex_dev);
                return 0;
+       }
 
        drm = drm_dev_alloc(&mtk_drm_driver, dev);
        if (IS_ERR(drm)) {
-- 
2.34.1

Reply via email to