media: platform: mtk-mdp3: fix PM reference leak in mdp_comp_clock_on()
authorSun Ke <sunke32@huawei.com>
Fri, 2 Sep 2022 08:58:19 +0000 (10:58 +0200)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Sat, 24 Sep 2022 06:53:43 +0000 (08:53 +0200)
commitff464745e4576ed8670bc2fc8da27e022f0ea56c
treec0646153a2f5da9156ee5684476560a604f16c36
parentdec7920e55db35ac429b002025aa1fafc0ec7d57
media: platform: mtk-mdp3: fix PM reference leak in mdp_comp_clock_on()

mdp_comp_clock_on will increase runtime PM usage counter,
and mdp_comp_clock_off will decrease the runtime PM usage counter.
so, if mdp_comp_clock_on failed after increment runtime PM usage
counter, it should decrease it before return a error code.

pm_runtime_get_sync will increment pm usage counter even it failed.
Forgetting to putting operation will result in reference leak here.
Fix it by replacing it with pm_runtime_resume_and_get to keep usage
counter balanced.

And if failed to enable clk, add pm_runtime_put() to decrease the
runtime PM usage counter.

Fixes: 61890ccaefaf ("media: platform: mtk-mdp3: add MediaTek MDP3 driver")
Signed-off-by: Sun Ke <sunke32@huawei.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.c