1 From stable+bounces-178978-greg=kroah.com@vger.kernel.org Mon Sep 8 23:48:46 2025
2 From: Sasha Levin <sashal@kernel.org>
3 Date: Mon, 8 Sep 2025 17:48:39 -0400
4 Subject: media: mediatek: vcodec: Fix a resource leak related to the scp device in FW initialization
5 To: stable@vger.kernel.org
6 Cc: Jiasheng Jiang <jiashengjiangcool@gmail.com>, Hans Verkuil <hverkuil@xs4all.nl>, Sasha Levin <sashal@kernel.org>
7 Message-ID: <20250908214839.2435036-1-sashal@kernel.org>
9 From: Jiasheng Jiang <jiashengjiangcool@gmail.com>
11 [ Upstream commit 4936cd5817af35d23e4d283f48fa59a18ef481e4 ]
13 On Mediatek devices with a system companion processor (SCP) the mtk_scp
14 structure has to be removed explicitly to avoid a resource leak.
15 Free the structure in case the allocation of the firmware structure fails
16 during the firmware initialization.
18 Fixes: 53dbe0850444 ("media: mtk-vcodec: potential null pointer deference in SCP")
19 Cc: stable@vger.kernel.org
20 Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com>
21 Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
23 Signed-off-by: Sasha Levin <sashal@kernel.org>
24 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
26 drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw_scp.c | 4 +++-
27 1 file changed, 3 insertions(+), 1 deletion(-)
29 --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw_scp.c
30 +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw_scp.c
31 @@ -65,8 +65,10 @@ struct mtk_vcodec_fw *mtk_vcodec_fw_scp_
34 fw = devm_kzalloc(&dev->plat_dev->dev, sizeof(*fw), GFP_KERNEL);
38 return ERR_PTR(-ENOMEM);
41 fw->ops = &mtk_vcodec_rproc_msg;