From: sashiko-bot@kernel.org
To: "Kyrie Wu" <kyrie.wu@mediatek.com>, devicetree@vger.kernel.org
Cc: robh@kernel.org, conor+dt@kernel.org, media-ci@linuxtv.org
Subject: Re: [PATCH v9 05/14] media: mediatek: vcodec: get share memory address
Date: Tue, 17 Nov 2026 03:58:12 +0000 [thread overview]
Message-ID: <sashiko-outbox-218174@kernel.org> (raw)
In-Reply-To: <20261117032950.1425556-6-kyrie.wu@mediatek.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] media: mediatek: vcodec: broken error checks for
mtk_vcodec_fw_map_dm_addr()
--
commit f8c6ecd0c5f49d45a4ff6d9ac44477ccdda67d46
Author: Kyrie Wu <kyrie.wu@mediatek.com>
media: mediatek: vcodec: get share memory address
This commit implements mtk_vcodec_vcp_dm_addr() to partition the VCP
shared memory buffer into regions for VSI, VP9 frame context, and AV1
tables, and updates the decoder drivers to query these regions when
running on VCP firmware.
> diff --git a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vcp.c b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vcp.c
> index 5ec7a67b51b67..49ba897630a54 100644
> --- a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vcp.c
> +++ b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_vcp.c
> @@ -483,8 +483,31 @@ static unsigned int mtk_vcodec_vcp_get_vdec_capa(struct mtk_vcodec_fw *fw)
> MTK_VDEC_IS_SUPPORT_10BIT | MTK_VDEC_IS_SUPPORT_EXT;
> }
>
> -static void *mtk_vcodec_vcp_dm_addr(struct mtk_vcodec_fw *fw, u32 dtcm_dmem_addr)
> +static unsigned int mtk_vcodec_vcp_get_venc_capa(struct mtk_vcodec_fw *fw)
> {
> + return 0;
> +}
> +
> +static void *mtk_vcodec_vcp_dm_addr(struct mtk_vcodec_fw *fw, u32 mem_type)
> +{
> + unsigned char *vsi_core = fw->vcp->vsi_core_addr;
> +
> + switch (mem_type) {
> + case ENCODER_MEM:
> + case VCODEC_LAT_MEM:
> + return fw->vcp->vsi_addr;
> + case VCODEC_CORE_MEM:
> + return vsi_core;
> + case VP9_FRAME_MEM:
> + return vsi_core + VCODEC_VSI_LEN;
> + case AV1_CDF_MEM:
> + return vsi_core + VCODEC_VSI_LEN + VP9_FRAME_SIZE;
> + case AV1_IQ_MEM:
> + return vsi_core + VCODEC_VSI_LEN + VP9_FRAME_SIZE + AV1_CDF_SIZE;
> + default:
> + break;
> + }
> +
> return NULL;
> }
[Severity: High]
Does mtk_vcodec_vcp_dm_addr() match the error return convention expected
by callers of mtk_vcodec_fw_map_dm_addr()?
The VPU and SCP .map_dm_addr implementations return ERR_PTR(-EINVAL) on
failure, whereas mtk_vcodec_vcp_dm_addr() returns NULL (or a small
non-NULL offset from NULL if fw->vcp->vsi_addr was not mapped, because
mtk_vcodec_vcp_load_firmware() sets vsi_core_addr to vsi_addr +
VCODEC_VSI_LEN unconditionally and leaves vsi_core_addr NULL for
ENCODER).
In vdec_av1_slice_init_cdf_table() and vdec_av1_slice_init_iq_table(), the
callers only check IS_ERR(), so a NULL return from mtk_vcodec_vcp_dm_addr()
causes a NULL pointer dereference in memcpy(). Conversely,
vdec_av1_slice_init(), vdec_vp9_slice_init_default_frame_ctx(), and
vdec_vp9_slice_init() only test for !ptr, which misses ERR_PTR(-EINVAL) on
SCP/VPU and dereferences the error pointer in kmemdup() or during frame
decoding. In addition, vdec_h264_slice_init() and vdec_hevc_slice_init()
assign the result of mtk_vcodec_fw_map_dm_addr() to inst->vsi_core_ext and
inst->vsi_core without checking for errors at all.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261117032950.1425556-1-kyrie.wu@mediatek.com?part=5
next prev parent reply other threads:[~2026-11-17 3:58 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 3:29 [PATCH v9 00/14] media: mediatek: vcodec: support video decoder in mt8196 Kyrie Wu
2026-11-17 3:29 ` [PATCH v9 01/14] media: mediatek: vcodec: support vcp architecture Kyrie Wu
2026-11-17 3:29 ` [PATCH v9 02/14] media: mediatek: vcodec: add driver to support vcp Kyrie Wu
2026-11-17 3:55 ` sashiko-bot
2026-11-17 3:29 ` [PATCH v9 03/14] media: mediatek: vcodec: add driver to support vcp encoder Kyrie Wu
2026-11-17 3:53 ` sashiko-bot
2026-11-17 3:29 ` [PATCH v9 04/14] media: mediatek: vcodec: get different firmware ipi id Kyrie Wu
2026-11-17 3:53 ` sashiko-bot
2026-11-17 3:29 ` [PATCH v9 05/14] media: mediatek: vcodec: get share memory address Kyrie Wu
2026-11-17 3:58 ` sashiko-bot [this message]
2026-11-17 3:29 ` [PATCH v9 06/14] media: mediatek: vcodec: add debug information Kyrie Wu
2026-11-17 3:29 ` [PATCH v9 07/14] media: mediatek: vcodec: send share memory address to vcp Kyrie Wu
2026-11-17 3:29 ` [PATCH v9 08/14] media: dt-bindings: mediatek,vcodec-subdev-decoder: Add MT8196 Kyrie Wu
2026-11-17 3:39 ` sashiko-bot
2026-11-17 3:29 ` [PATCH v9 09/14] media: mediatek: vcodec: add decoder compatible to support mt8196 Kyrie Wu
2026-11-17 3:29 ` [PATCH v9 10/14] media: mediatek: vcodec: define MT8196 vcodec levels Kyrie Wu
2026-11-17 3:29 ` [PATCH v9 11/14] media: mediatek: vcodec: support 36bit iova address Kyrie Wu
2026-11-17 3:29 ` [PATCH v9 12/14] media: mediatek: vcodec: clean xpc status Kyrie Wu
2026-11-17 4:04 ` sashiko-bot
2026-11-17 3:29 ` [PATCH v9 13/14] media: mediatek: decoder: fill av1 buffer size with picinfo Kyrie Wu
2026-11-17 3:29 ` [PATCH v9 14/14] media: mediatek: decoder: support av1 extend vsi Kyrie Wu
2026-11-17 4:14 ` sashiko-bot
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=sashiko-outbox-218174@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=kyrie.wu@mediatek.com \
--cc=media-ci@linuxtv.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.