From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
To: Jiasheng Jiang <jiasheng@iscas.ac.cn>,
mchehab@kernel.org, matthias.bgg@gmail.com,
moudy.ho@mediatek.com, daoyuan.huang@mediatek.com,
hverkuil-cisco@xs4all.nl
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org
Subject: Re: [PATCH v3] media: platform: mtk-mdp3: Add missing check and free for ida_alloc
Date: Thu, 9 Feb 2023 14:21:13 +0100 [thread overview]
Message-ID: <14602081-c361-70e2-afd1-4f5dad8e2869@collabora.com> (raw)
In-Reply-To: <20230209092502.34300-1-jiasheng@iscas.ac.cn>
Il 09/02/23 10:25, Jiasheng Jiang ha scritto:
> Add the check for the return value of the ida_alloc in order to avoid
> NULL pointer dereference.
> Moreover, free allocated "ctx->id" if mdp_m2m_open fails later in order
> to avoid memory leak.
>
> Fixes: 61890ccaefaf ("media: platform: mtk-mdp3: add MediaTek MDP3 driver")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
> Changelog:
>
> v2 -> v3:
>
> 1. Fix the goto label.
>
> v1 -> v2:
>
> 1. Fix the check for the ida_alloc.
> ---
> drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c
> index 5f74ea3b7a52..a2d204e90aa4 100644
> --- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c
> +++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-m2m.c
> @@ -567,6 +567,11 @@ static int mdp_m2m_open(struct file *file)
> }
>
> ctx->id = ida_alloc(&mdp->mdp_ida, GFP_KERNEL);
> + if (ctx->id < 0) {
There's one main not-so-minor issue here: ctx->id is u32.
Unsigned types cannot evaluate less than zero: they're .. unsigned!
There's your fix:
ret = ida_alloc ...
if (ret)
....
ctx->id = ret;
Enjoy.
Regards,
Angelo
prev parent reply other threads:[~2023-02-09 13:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-09 9:25 Jiasheng Jiang
2023-02-09 13:21 ` AngeloGioacchino Del Regno [this message]
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=14602081-c361-70e2-afd1-4f5dad8e2869@collabora.com \
--to=angelogioacchino.delregno@collabora.com \
--cc=daoyuan.huang@mediatek.com \
--cc=hverkuil-cisco@xs4all.nl \
--cc=jiasheng@iscas.ac.cn \
--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=moudy.ho@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®