From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
To: Nicolas Dufresne <nicolas.dufresne@collabora.com>,
Anastasia Belova <abelova@astralinux.ru>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Matthias Brugger <matthias.bgg@gmail.com>
Cc: Tiffany Lin <tiffany.lin@mediatek.com>,
Andrew-CT Chen <andrew-ct.chen@mediatek.com>,
Yunfei Dong <yunfei.dong@mediatek.com>,
Hans Verkuil <hverkuil-cisco@xs4all.nl>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, lvc-project@linuxtesting.org
Subject: Re: [PATCH] vcodec: mediatek: add check for NULL for vsi->frm_bufs[vsi->new_fb_idx].buf.fb in vp9_swap_frm_bufs
Date: Mon, 31 Oct 2022 13:48:45 +0100 [thread overview]
Message-ID: <2fbf35b9-3cad-4211-db5b-501d5eb14a2e@collabora.com> (raw)
In-Reply-To: <664bd195bdde7fd740572c4981c60b32de1465aa.camel@collabora.com>
Il 28/10/22 15:02, Nicolas Dufresne ha scritto:
> Hi,
>
> Le vendredi 28 octobre 2022 à 15:58 +0300, Anastasia Belova a écrit :
>> If vsi->frm_bufs[vsi->new_fb_idx].buf.fb == NULL while cleaning
>> fb_free_list NULL-pointer is dereferenced.
>>
>> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>>
>> Fixes: f77e89854b3e ("[media] vcodec: mediatek: Add Mediatek VP9 Video Decoder Driver")
>>
>> Signed-off-by: Anastasia Belova <abelova@astralinux.ru>
>> ---
>> drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_if.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_if.c b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_if.c
>> index 70b8383f7c8e..b0679aaf6192 100644
>> --- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_if.c
>> +++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_if.c
>> @@ -512,7 +512,7 @@ static void vp9_swap_frm_bufs(struct vdec_vp9_inst *inst)
>> * clean fb_free_list
>> */
>> if (vsi->frm_bufs[vsi->new_fb_idx].ref_cnt == 0) {
>> - if (!vp9_is_sf_ref_fb(
>> + if (vsi->frm_bufs[vsi->new_fb_idx].buf.fb != NULL && !vp9_is_sf_ref_fb(
>> inst, vsi->frm_bufs[vsi->new_fb_idx].buf.fb)) {
>> struct vdec_fb *fb;
>
> Perhaps we could try and maintain some readability ? I'd suggest to move the
> check into vp9_is_sf_ref_fb() as an early return.
>
I don't think that this will ever happen, as the check was omitted because of being
totally sure that vsi->frm_bufs[vsi->new_fb_idx].buf.fb is not NULL.
In any case, it doesn't really cost anything to add a check... in which case, I
agree with Nicolas about moving that to vp9_is_sf_ref_fb().
if (!fb)
return false
for .....
Regards,
Angelo
prev parent reply other threads:[~2022-10-31 12:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-28 12:58 Anastasia Belova
2022-10-28 13:02 ` Nicolas Dufresne
2022-10-31 12:48 ` 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=2fbf35b9-3cad-4211-db5b-501d5eb14a2e@collabora.com \
--to=angelogioacchino.delregno@collabora.com \
--cc=abelova@astralinux.ru \
--cc=andrew-ct.chen@mediatek.com \
--cc=hverkuil-cisco@xs4all.nl \
--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=lvc-project@linuxtesting.org \
--cc=matthias.bgg@gmail.com \
--cc=mchehab@kernel.org \
--cc=nicolas.dufresne@collabora.com \
--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®