Skip to content

Commit 69dd5bb

Browse files
Jiasheng Jianggregkh
authored andcommitted
media: mediatek: vcodec: Fix a resource leak related to the scp device in FW initialization
[ Upstream commit 4936cd5 ] 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> [ Adapted file path ] Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 80fc7c7 commit 69dd5bb

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,10 @@ struct mtk_vcodec_fw *mtk_vcodec_fw_scp_init(struct mtk_vcodec_dev *dev)
6565
}
6666

6767
fw = devm_kzalloc(&dev->plat_dev->dev, sizeof(*fw), GFP_KERNEL);
68-
if (!fw)
68+
if (!fw) {
69+
scp_put(scp);
6970
return ERR_PTR(-ENOMEM);
71+
}
7072
fw->type = SCP;
7173
fw->ops = &mtk_vcodec_rproc_msg;
7274
fw->scp = scp;

0 commit comments

Comments
 (0)