From: Irui Wang <irui.wang@mediatek.com>
To: Hans Verkuil <hverkuil-cisco@xs4all.nl>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
<angelogioacchino.delregno@collabora.com>,
<nicolas.dufresne@collabora.com>
Cc: <Project_Global_Chrome_Upstream_Group@mediatek.com>,
<linux-media@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-mediatek@lists.infradead.org>,
Yunfei Dong <yunfei.dong@mediatek.com>,
Longfei Wang <longfei.wang@mediatek.com>,
Irui Wang <irui.wang@mediatek.com>
Subject: [PATCH v2] media: mediatek: encoder: Fix uninitialized scalar variable issue
Date: Wed, 16 Jul 2025 15:14:50 +0800 [thread overview]
Message-ID: <20250716071450.8214-1-irui.wang@mediatek.com> (raw)
UNINIT checker finds some instances of variables that are used
without being initialized, for example using the uninitialized
value enc_result.is_key_frm can result in unpredictable behavior,
so initialize these variables after declaring.
Fixes: 4e855a6efa54 ("[media] vcodec: mediatek: Add Mediatek V4L2 Video Encoder Driver")
Signed-off-by: Irui Wang <irui.wang@mediatek.com>
---
v2:
- Add Fixes tag, update commit message
- Remove unnecessary memset
- Move memset to before the first usage
---
.../media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc.c b/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc.c
index a01dc25a7699..3065f3e66336 100644
--- a/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc.c
+++ b/drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc.c
@@ -865,7 +865,7 @@ static void vb2ops_venc_buf_queue(struct vb2_buffer *vb)
static int vb2ops_venc_start_streaming(struct vb2_queue *q, unsigned int count)
{
struct mtk_vcodec_enc_ctx *ctx = vb2_get_drv_priv(q);
- struct venc_enc_param param;
+ struct venc_enc_param param = { 0 };
int ret;
int i;
@@ -1036,6 +1036,7 @@ static int mtk_venc_encode_header(void *priv)
ctx->id, dst_buf->vb2_buf.index, bs_buf.va,
(u64)bs_buf.dma_addr, bs_buf.size);
+ memset(&enc_result, 0, sizeof(enc_result));
ret = venc_if_encode(ctx,
VENC_START_OPT_ENCODE_SEQUENCE_HEADER,
NULL, &bs_buf, &enc_result);
@@ -1185,6 +1186,7 @@ static void mtk_venc_worker(struct work_struct *work)
(u64)frm_buf.fb_addr[1].dma_addr, frm_buf.fb_addr[1].size,
(u64)frm_buf.fb_addr[2].dma_addr, frm_buf.fb_addr[2].size);
+ memset(&enc_result, 0, sizeof(enc_result));
ret = venc_if_encode(ctx, VENC_START_OPT_ENCODE_FRAME,
&frm_buf, &bs_buf, &enc_result);
--
2.46.0
next reply other threads:[~2025-07-16 7:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-16 7:14 Irui Wang [this message]
2025-08-29 19:10 ` Nicolas Dufresne
2025-09-01 2:37 ` Irui Wang (王瑞)
2025-09-02 12:57 ` Nicolas Dufresne
2025-09-07 9:44 ` Irui Wang (王瑞)
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=20250716071450.8214-1-irui.wang@mediatek.com \
--to=irui.wang@mediatek.com \
--cc=Project_Global_Chrome_Upstream_Group@mediatek.com \
--cc=angelogioacchino.delregno@collabora.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=longfei.wang@mediatek.com \
--cc=matthias.bgg@gmail.com \
--cc=mchehab@kernel.org \
--cc=nicolas.dufresne@collabora.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®