[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20250131012830.22394-1-jiashengjiangcool@gmail.com>
Date: Fri, 31 Jan 2025 01:28:30 +0000
From: Jiasheng Jiang <jiashengjiangcool@...il.com>
To: tiffany.lin@...iatek.com,
andrew-ct.chen@...iatek.com,
yunfei.dong@...iatek.com,
mchehab@...nel.org,
matthias.bgg@...il.com,
angelogioacchino.delregno@...labora.com,
fullwaywang@...look.com
Cc: linux-media@...r.kernel.org,
linux-kernel@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
linux-mediatek@...ts.infradead.org,
Jiasheng Jiang <jiashengjiangcool@...il.com>
Subject: [PATCH] media: mediatek: vcodec: Add scp_put() to free the scp
Add scp_put() to free the scp if devm_kzalloc() fails to avoid memory
leak.
Fixes: 53dbe0850444 ("media: mtk-vcodec: potential null pointer deference in SCP")
Signed-off-by: Jiasheng Jiang <jiashengjiangcool@...il.com>
---
.../platform/mediatek/vcodec/common/mtk_vcodec_fw_scp.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_scp.c b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_scp.c
index ff23b225db70..1b0bc47355c0 100644
--- a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_scp.c
+++ b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_scp.c
@@ -79,8 +79,11 @@ struct mtk_vcodec_fw *mtk_vcodec_fw_scp_init(void *priv, enum mtk_vcodec_fw_use
}
fw = devm_kzalloc(&plat_dev->dev, sizeof(*fw), GFP_KERNEL);
- if (!fw)
+ if (!fw) {
+ scp_put(scp);
return ERR_PTR(-ENOMEM);
+ }
+
fw->type = SCP;
fw->ops = &mtk_vcodec_rproc_msg;
fw->scp = scp;
--
2.25.1
Powered by blists - more mailing lists