From: "Irui Wang (王瑞)" <Irui.Wang@mediatek.com>
To: "matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
"mchehab@kernel.org" <mchehab@kernel.org>,
"angelogioacchino.delregno@collabora.com"
<angelogioacchino.delregno@collabora.com>,
"nicolas.dufresne@collabora.com" <nicolas.dufresne@collabora.com>,
"hverkuil-cisco@xs4all.nl" <hverkuil-cisco@xs4all.nl>,
"Yunfei Dong (董云飞)" <Yunfei.Dong@mediatek.com>
Cc: "linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-media@vger.kernel.org" <linux-media@vger.kernel.org>,
"linux-mediatek@lists.infradead.org"
<linux-mediatek@lists.infradead.org>,
"Maoguang Meng (孟毛广)" <Maoguang.Meng@mediatek.com>,
Project_Global_Chrome_Upstream_Group
<Project_Global_Chrome_Upstream_Group@mediatek.com>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>
Subject: Re: [PATCH 2/2] media: mediatek: vcodec: Handle encoder vsi NULL pointer case
Date: Sat, 7 Oct 2023 06:16:21 +0000 [thread overview]
Message-ID: <bfac65fcd5df18fd31db4b0d326b0dec48ae88e1.camel@mediatek.com> (raw)
In-Reply-To: <b7c19673-a3bd-449a-9e84-49a68c89b0ea@xs4all.nl>
Dear Angelo, Hans,
Thanks for your reviewing.
I will send patch v2 with Fix tag...
....
On Thu, 2023-10-05 at 10:43 +0200, Hans Verkuil wrote:
>
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
> On 26/09/2023 12:19, Irui Wang wrote:
> > There will be a kernel null pointer exception if 'vsi' is NULL,
> check
> > 'vsi' is not NULL before assign it to encoder instance.
> >
> > Signed-off-by: Irui Wang <irui.wang@mediatek.com>
> > ---
> > .../platform/mediatek/vcodec/encoder/venc/venc_h264_if.c | 5
> +++++
> > .../platform/mediatek/vcodec/encoder/venc/venc_vp8_if.c | 5
> +++++
> > 2 files changed, 10 insertions(+)
> >
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/encoder/venc/venc_h264_if.c
> b/drivers/media/platform/mediatek/vcodec/encoder/venc/venc_h264_if.c
> > index a68dac72c4e4..385bcc0d14f3 100644
> > ---
> a/drivers/media/platform/mediatek/vcodec/encoder/venc/venc_h264_if.c
> > +++
> b/drivers/media/platform/mediatek/vcodec/encoder/venc/venc_h264_if.c
> > @@ -597,6 +597,11 @@ static int h264_enc_init(struct
> mtk_vcodec_enc_ctx *ctx)
> > inst->hw_base = mtk_vcodec_get_reg_addr(inst->ctx->dev->reg_base,
> VENC_SYS);
> >
> > ret = vpu_enc_init(&inst->vpu_inst);
> > +if (!inst->vpu_inst.vsi) {
> > +mtk_venc_err(ctx, "share buffer is NULL");
> > +kfree(inst);
> > +return -EFAULT;
> > +}
>
> Shouldn't this check be done in vpu_enc_init?
> It looks weird that a function can return 0, but there is still an
> error that needs to be checked manually afterwards.
>
> Regards,
>
> Hans
Also, this check will move into vpu_enc_init.
Best Regards
>
> >
> > if (MTK_ENC_IOVA_IS_34BIT(ctx))
> > inst->vsi_34 = (struct venc_h264_vsi_34 *)inst->vpu_inst.vsi;
> > diff --git
> a/drivers/media/platform/mediatek/vcodec/encoder/venc/venc_vp8_if.c
> b/drivers/media/platform/mediatek/vcodec/encoder/venc/venc_vp8_if.c
> > index 05abca91e742..23ca0d93324f 100644
> > ---
> a/drivers/media/platform/mediatek/vcodec/encoder/venc/venc_vp8_if.c
> > +++
> b/drivers/media/platform/mediatek/vcodec/encoder/venc/venc_vp8_if.c
> > @@ -326,6 +326,11 @@ static int vp8_enc_init(struct
> mtk_vcodec_enc_ctx *ctx)
> > inst->hw_base = mtk_vcodec_get_reg_addr(inst->ctx->dev->reg_base,
> VENC_LT_SYS);
> >
> > ret = vpu_enc_init(&inst->vpu_inst);
> > +if (!inst->vpu_inst.vsi) {
> > +mtk_venc_err(ctx, "share buffer is NULL");
> > +kfree(inst);
> > +return -EFAULT;
> > +}
> >
> > inst->vsi = (struct venc_vp8_vsi *)inst->vpu_inst.vsi;
> >
>
next prev parent reply other threads:[~2023-10-07 6:17 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-26 10:19 [PATCH 1/2] media: mediatek: vcodec: Fix encoder access NULL pointer Irui Wang
2023-09-26 10:19 ` [PATCH 2/2] media: mediatek: vcodec: Handle encoder vsi NULL pointer case Irui Wang
2023-10-02 10:25 ` Hans Verkuil
2023-10-02 10:48 ` AngeloGioacchino Del Regno
2023-10-02 11:34 ` AngeloGioacchino Del Regno
2023-10-05 8:43 ` Hans Verkuil
2023-10-07 6:16 ` Irui Wang (王瑞) [this message]
2023-10-02 10:24 ` [PATCH 1/2] media: mediatek: vcodec: Fix encoder access NULL pointer Hans Verkuil
2023-10-04 6:54 ` Hans Verkuil
2023-10-05 8:46 ` Hans Verkuil
2023-10-07 1:49 ` Irui Wang (王瑞)
2023-10-02 10:48 ` AngeloGioacchino Del Regno
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=bfac65fcd5df18fd31db4b0d326b0dec48ae88e1.camel@mediatek.com \
--to=irui.wang@mediatek.com \
--cc=Maoguang.Meng@mediatek.com \
--cc=Project_Global_Chrome_Upstream_Group@mediatek.com \
--cc=Yunfei.Dong@mediatek.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=devicetree@vger.kernel.org \
--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=matthias.bgg@gmail.com \
--cc=mchehab@kernel.org \
--cc=nicolas.dufresne@collabora.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
Powered by JetHome