mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nicolas Dufresne <nicolas@ndufresne.ca>
To: Miaoqian Lin <linmq006@gmail.com>,
	Tiffany Lin <tiffany.lin@mediatek.com>,
	 Andrew-CT Chen <andrew-ct.chen@mediatek.com>,
	Yunfei Dong <yunfei.dong@mediatek.com>,
	Mauro Carvalho Chehab	 <mchehab@kernel.org>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	 AngeloGioacchino Del Regno
	<angelogioacchino.delregno@collabora.com>,
	Fullway Wang <fullwaywang@outlook.com>,
		linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
		linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org
Subject: Re: [PATCH] media: mtk-vcodec: Fix reference count leak in mtk_vcodec_fw_scp_init
Date: Wed, 02 Apr 2025 11:37:32 -0400	[thread overview]
Message-ID: <cfc905988dda23078b5086f3eb0975863bbb6c2d.camel@ndufresne.ca> (raw)
In-Reply-To: <20250318110556.903-1-linmq006@gmail.com>

Hi,

Le mardi 18 mars 2025 à 19:05 +0800, Miaoqian Lin a écrit :
> scp_get() returns a reference that needs to be released with scp_put().
> Add missing scp_put() before returning error in mtk_vcodec_fw_scp_init().
> 
> Fixes: 53dbe0850444 ("media: mtk-vcodec: potential null pointer deference in SCP")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
> ---
>  .../platform/mediatek/vcodec/common/mtk_vcodec_fw_scp.c      | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> 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..11ab3bc60217 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
> @@ -71,7 +71,6 @@ struct mtk_vcodec_fw *mtk_vcodec_fw_scp_init(void *priv, enum mtk_vcodec_fw_use
>  		pr_err("Invalid fw_use %d (use a reasonable fw id here)\n", fw_use);
>  		return ERR_PTR(-EINVAL);
>  	}
> -

Might sound nit-picky, but don't do style fixes in patches intended for
backports. It increases the chance of conflicts.

>  	scp = scp_get(plat_dev);
>  	if (!scp) {
>  		dev_err(&plat_dev->dev, "could not get vdec scp handle");
> @@ -79,8 +78,10 @@ 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);
> +	}

With the above style change removed:

Reviewed-by: Nicolas Dufresne <nicolas.dufresne@colllabora.com>

>  	fw->type = SCP;
>  	fw->ops = &mtk_vcodec_rproc_msg;
>  	fw->scp = scp;

  reply	other threads:[~2025-04-02 15:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-18 11:05 Miaoqian Lin
2025-04-02 15:37 ` Nicolas Dufresne [this message]
2025-04-02 15:40   ` Nicolas Dufresne

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=cfc905988dda23078b5086f3eb0975863bbb6c2d.camel@ndufresne.ca \
    --to=nicolas@ndufresne.ca \
    --cc=andrew-ct.chen@mediatek.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=fullwaywang@outlook.com \
    --cc=linmq006@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®