Skip to content

Commit 4936cd5

Browse files
Jiasheng Jianghverkuil
authored andcommitted
media: mediatek: vcodec: Fix a resource leak related to the scp device in FW initialization
On Mediatek devices with a system companion processor (SCP) the mtk_scp structure has to be removed explicitly to avoid a resource leak. Free the structure in case the allocation of the firmware structure fails during the firmware initialization. Fixes: 53dbe08 ("media: mtk-vcodec: potential null pointer deference in SCP") Cc: stable@vger.kernel.org Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
1 parent 7b0ee2d commit 4936cd5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_scp.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,11 @@ struct mtk_vcodec_fw *mtk_vcodec_fw_scp_init(void *priv, enum mtk_vcodec_fw_use
7979
}
8080

8181
fw = devm_kzalloc(&plat_dev->dev, sizeof(*fw), GFP_KERNEL);
82-
if (!fw)
82+
if (!fw) {
83+
scp_put(scp);
8384
return ERR_PTR(-ENOMEM);
85+
}
86+
8487
fw->type = SCP;
8588
fw->ops = &mtk_vcodec_rproc_msg;
8689
fw->scp = scp;

0 commit comments

Comments
 (0)