| From c23167caeb0f7ec46e6b3ec74c3dca2706cd8f84 Mon Sep 17 00:00:00 2001 |
| From: Sasha Levin <sashal@kernel.org> |
| Date: Thu, 19 Aug 2021 22:21:25 +0200 |
| Subject: media: mtk-vpu: Fix a resource leak in the error handling path of |
| 'mtk_vpu_probe()' |
| |
| From: Christophe JAILLET <christophe.jaillet@wanadoo.fr> |
| |
| [ Upstream commit 2143ad413c05c7be24c3a92760e367b7f6aaac92 ] |
| |
| A successful 'clk_prepare()' call should be balanced by a corresponding |
| 'clk_unprepare()' call in the error handling path of the probe, as already |
| done in the remove function. |
| |
| Update the error handling path accordingly. |
| |
| Fixes: 3003a180ef6b ("[media] VPU: mediatek: support Mediatek VPU") |
| Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> |
| Reviewed-by: Houlong Wei <houlong.wei@mediatek.com> |
| Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> |
| Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> |
| Signed-off-by: Sasha Levin <sashal@kernel.org> |
| --- |
| drivers/media/platform/mtk-vpu/mtk_vpu.c | 5 ++++- |
| 1 file changed, 4 insertions(+), 1 deletion(-) |
| |
| diff --git a/drivers/media/platform/mtk-vpu/mtk_vpu.c b/drivers/media/platform/mtk-vpu/mtk_vpu.c |
| index cc2ff40d060d1..acf64723f9381 100644 |
| --- a/drivers/media/platform/mtk-vpu/mtk_vpu.c |
| +++ b/drivers/media/platform/mtk-vpu/mtk_vpu.c |
| @@ -809,7 +809,8 @@ static int mtk_vpu_probe(struct platform_device *pdev) |
| vpu->wdt.wq = create_singlethread_workqueue("vpu_wdt"); |
| if (!vpu->wdt.wq) { |
| dev_err(dev, "initialize wdt workqueue failed\n"); |
| - return -ENOMEM; |
| + ret = -ENOMEM; |
| + goto clk_unprepare; |
| } |
| INIT_WORK(&vpu->wdt.ws, vpu_wdt_reset_func); |
| mutex_init(&vpu->vpu_mutex); |
| @@ -908,6 +909,8 @@ disable_vpu_clk: |
| vpu_clock_disable(vpu); |
| workqueue_destroy: |
| destroy_workqueue(vpu->wdt.wq); |
| +clk_unprepare: |
| + clk_unprepare(vpu->clk); |
| |
| return ret; |
| } |
| -- |
| 2.33.0 |
| |