From: Sebastian Fricke <sebastian.fricke@collabora.com>
To: "Jiasheng Jiang" <jiashengjiangcool@gmail.com>
Cc: "tiffany.lin" <tiffany.lin@mediatek.com>,
"andrew-ct.chen" <andrew-ct.chen@mediatek.com>,
"yunfei.dong" <yunfei.dong@mediatek.com>,
"mchehab" <mchehab@kernel.org>,
"matthias.bgg" <matthias.bgg@gmail.com>,
"angelogioacchino.delregno"
<angelogioacchino.delregno@collabora.com>,
"fullwaywang" <fullwaywang@outlook.com>,
"linux-media" <linux-media@vger.kernel.org>,
"linux-kernel" <linux-kernel@vger.kernel.org>,
"linux-arm-kernel" <linux-arm-kernel@lists.infradead.org>,
"linux-mediatek" <linux-mediatek@lists.infradead.org>
Subject: Re: [PATCH] media: mediatek: vcodec: Add scp_put() to free the scp
Date: Fri, 14 Feb 2025 21:20:27 +0100 [thread overview]
Message-ID: <195061eaa10.dcfe0edc1589793.425795569509706466@collabora.com> (raw)
In-Reply-To: <20250131012830.22394-1-jiashengjiangcool@gmail.com>
Hey Jiasheng,
---- On Fri, 31 Jan 2025 02:28:30 +0100 Jiasheng Jiang <jiashengjiangcool@gmail.com> wrote ---
> Add scp_put() to free the scp if devm_kzalloc() fails to avoid memory
> leak.
Your commit message sounds a bit like you copy-pasted your code into the commit message.
What kind of memory is leaking here? Are we talking about SRAM memory?
I'd reword the commit message to something like this to give a bit more context:
On Mediatek devices with a system companion processor (SCP) the mtk_scp structure has to be removed explicitly to avoid a memory leak.
Free the structure in case the allocation of the firmware structure fails during the firmware initialization.
---
Additionally, the commit title says close to nothing to the reader as well.
How about: Fix memory leak in FW initialization
But as I stated above you should clarify what kind of memory we are talking about here.
Also just out of interest have you ever actually experienced issues with this?
It seems to me that the situation where you run out of Kernel memory should be quite rare.
Regards,
Sebastian
>
> Fixes: 53dbe0850444 ("media: mtk-vcodec: potential null pointer deference in SCP")
> Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.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
>
>
>
next prev parent reply other threads:[~2025-02-14 20:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-31 1:28 Jiasheng Jiang
2025-02-14 20:20 ` Sebastian Fricke [this message]
2025-02-18 18:22 ` Jiasheng Jiang
2025-02-18 18:58 ` [PATCH v2] media: mediatek: vcodec: Fix a resource leak related to the scp device in FW initialization Jiasheng Jiang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=195061eaa10.dcfe0edc1589793.425795569509706466@collabora.com \
--to=sebastian.fricke@collabora.com \
--cc=andrew-ct.chen@mediatek.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=fullwaywang@outlook.com \
--cc=jiashengjiangcool@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=mchehab@kernel.org \
--cc=tiffany.lin@mediatek.com \
--cc=yunfei.dong@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®