From: sashiko-bot@kernel.org
To: "Yunfei Dong" <yunfei.dong@mediatek.com>
Cc: robh@kernel.org, media-ci@linuxtv.org, conor+dt@kernel.org,
devicetree@vger.kernel.org
Subject: Re: [PATCH v4 08/14] media: mediatek: vcodec: clean xpc status
Date: Thu, 13 Aug 2026 23:15:20 +0000 [thread overview]
Message-ID: <20260813231520.C17301F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260328051630.7937-9-yunfei.dong@mediatek.com>
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
New issues:
- [High] Unprotected read-modify-write on the shared VDEC_XPC_CLEAN_ADDR register from concurrent interrupt handlers causes a data race.
- [Medium] Missing bounds check on DT register properties can cause a NULL pointer dereference in mtk_vdec_hw_clean_xpc().
- [Low] Indexing `main_dev->reg_base` using an enum value from a mismatched enum family.
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but a dangling pointer in the main device structure after a subdevice probe failure leads to a Use-After-Free.
- [High] This problem wasn't introduced by this patch, but an unchecked context dereference in the hardware IRQ handler leads to a NULL pointer dereference.
--
--- Patch [8]: [PATCH v4 08/14] media: mediatek: vcodec: clean xpc status ---
Note: The format of this review has been altered to provide a free-form
summary without directly quoting the original patch code due to system
recitation restrictions.
Commit: 21f18ceee1ef481effb4080e344810308dfee5b9
Author: Yunfei Dong <yunfei.dong@mediatek.com>
Subject: media: mediatek: vcodec: clean xpc status
Summary: The driver needs to clean xpc status when receiving decoder hardware
interrupt for mt8196 platform.
[Severity: High]
In mtk_vdec_hw_write_reg_mask(), the code performs a read-modify-write
sequence on the register via readl() and writel(). Since
mtk_vdec_hw_clean_xpc() is called from mtk_vdec_hw_irq_handler() for
multiple independent subdevices (like LAT and CORE) that can fire
concurrently on different CPUs, is it possible for these MMIO accesses to
race? If they race on the shared VDEC_XPC_CLEAN_ADDR register without a
spinlock, could hardware register updates be lost?
[Severity: Low]
Looking at mtk_vdec_hw_probe(), subdev_dev->reg_base[VDEC_HW_XPC] is
assigned using main_dev->reg_base[VDEC_HW_MISC]. Does this index into
main_dev->reg_base using the wrong enum family? It seems main_dev->reg_base
should logically be indexed by enum mtk_hw_reg_idx (where VDEC_MISC is 1),
but it is using VDEC_HW_MISC from enum mtk_vdec_hw_reg_idx. While these
currently share the same integer value, could this silently break if the
enums are ever modified?
[Severity: High]
This isn't a bug introduced by this patch, but looking at
mtk_vdec_hw_probe(), subdev_dev is assigned to main_dev->subdev_dev[hw_idx]
and marked active in subdev_bitmap before the rest of the initialization
finishes. If a subsequent step like devm_platform_ioremap_resource() fails,
the probe returns an error and devm frees subdev_dev. Does this leave a
dangling pointer in the parent's array? Since the bit remains set in
subdev_bitmap, mtk_vdec_hw_prob_done() might consider it ready, potentially
leading to a use-after-free when mtk_vcodec_get_hw_dev() dereferences it.
[Severity: Medium]
In mtk_vdec_hw_probe(), subdev_dev->reg_base[VDEC_HW_XPC] inherits the
pointer from main_dev->reg_base[VDEC_HW_MISC]. If the device tree is
malformed and provides fewer register bases than expected (for example,
only 1 instead of the required number), could
main_dev->reg_base[VDEC_HW_MISC] be NULL? If so, when an interrupt fires,
would mtk_vdec_hw_clean_xpc() blindly access this NULL pointer via readl(),
causing a kernel panic?
[Severity: High]
This is a pre-existing issue, but in mtk_vdec_hw_irq_handler(),
mtk_vcodec_get_curr_ctx() is called to fetch the context. Can this function
legitimately return NULL, for instance during spurious interrupts or early
teardown? If ctx is NULL, wouldn't passing it directly to
mtk_v4l2_vdec_err() and wake_up_dec_ctx() cause an immediate NULL pointer
dereference, as both unconditionally dereference it without checking?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260328051630.7937-1-yunfei.dong@mediatek.com?part=8
next prev parent reply other threads:[~2026-08-13 23:15 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-28 5:16 [PATCH v4 00/14] media: mediatek: vcodec: support video decoder in mt8196 Yunfei Dong
2026-03-28 5:16 ` [PATCH v4 01/14] media: mediatek: vcodec: add driver to support vcp Yunfei Dong
2026-04-28 20:29 ` Nicolas Dufresne
2026-03-28 5:16 ` [PATCH v4 02/14] media: mediatek: vcodec: add driver to support vcp encoder Yunfei Dong
2026-03-28 5:16 ` [PATCH v4 03/14] media: mediatek: vcodec: get different firmware ipi id Yunfei Dong
2026-03-28 5:16 ` [PATCH v4 04/14] media: mediatek: vcodec: get share memory address Yunfei Dong
2026-03-28 5:16 ` [PATCH v4 05/14] media: mediatek: vcodec: define MT8196 vcodec levels Yunfei Dong
2026-03-28 5:16 ` [PATCH v4 06/14] media: mediatek: vcodec: support vcp architecture Yunfei Dong
2026-03-28 5:16 ` [PATCH v4 07/14] media: mediatek: vcodec: support 36bit iova address Yunfei Dong
2026-03-28 5:16 ` [PATCH v4 08/14] media: mediatek: vcodec: clean xpc status Yunfei Dong
2026-08-13 23:15 ` sashiko-bot [this message]
2026-03-28 5:16 ` [PATCH v4 09/14] media: mediatek: vcodec: add debug information Yunfei Dong
2026-03-28 5:16 ` [PATCH v4 10/14] media: mediatek: vcodec: send share memory address to vcp Yunfei Dong
2026-03-28 5:16 ` [PATCH v4 11/14] dt-bindings: media: mediatek: vcodec: add decoder dt-bindings for mt8196 Yunfei Dong
2026-03-28 12:22 ` Krzysztof Kozlowski
2026-03-28 5:16 ` [PATCH v4 12/14] media: mediatek: vcodec: add decoder compatible to support mt8196 Yunfei Dong
2026-03-28 5:16 ` [PATCH v4 13/14] media: mediatek: decoder: fill av1 buffer size with picinfo Yunfei Dong
2026-03-28 5:16 ` [PATCH v4 14/14] media: mediatek: decoder: support av1 extend vsi Yunfei Dong
2026-04-28 20:24 ` [PATCH v4 00/14] media: mediatek: vcodec: support video decoder in mt8196 Nicolas Dufresne
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=20260813231520.C17301F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=media-ci@linuxtv.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--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