Re: [PATCH v7 00/19] media: meson: vdec: Fix lifecycles, race conditions, and stability bugs
From: Anand Moon
Date: Tue Jul 14 2026 - 03:24:20 EST
Hi All,
On Mon, 13 Jul 2026 at 17:38, Anand Moon <linux.amoon@xxxxxxxxx> wrote:
>
> This patch series addresses a collection of critical race conditions,
> memory leaks, use-after-free bugs, and resource management issues
> within the Amlogic Meson video decoder (meson-vdec) driver and
> associated components.
>
> The primary focus is tightening session lifecycles, safely synchronising
> the V4L2 m2m framework callbacks, hardening work queue operations
> (esparser_queue_work), and correcting buffer validations to prevent
> stability issues like KASAN out-of-bounds errors or stream-on timeouts.
>
> Summary of Changes:
> * Race Conditions & Synchronisation: Fixes multi-threading and
> execution races across stream-on, stream-off, job abort, and
> teardown pathways.
> * Memory Lifecycle: Eliminates memory leaks and use-after-free
> vulnerabilities by safely pinning, canceling, and sequencing
> device removals.
> * VP9 & Buffer Hardening: Addresses payload handling bugs in the ES
> parser, properly tracks ongoing buffers via atomic counters, and
> prevents invalid memory writes.
> * Platform/DMA Adjustments: Adjusts DMA segment configurations,
> canvas handling, and buffer sizes to match modern hardware demands.
>
> Note on an outstanding issue:
> An execution deadlock occurs in the driver workqueue path during high
> stress or long playback sessions. This stall is triggered when the
> Amlogic hardware internal video FIFO buffer becomes completely full.
> When esparser_queue_all_src runs, the capacity validation check is
> tripped due to a design limitation in how buffer exhaustion is handled.
> This blocks progress and leaves the workqueue worker waiting indefinitely
> on a core mutex lock.
>
> The resulting hung task call trace shows the worker thread blocking
> on the internal lock:
>
> Workqueue: events esparser_queue_all_src [meson_vdec]
> ...
> __mutex_lock
> mutex_lock_nested
> esparser_queue_all_src
>
> I have tried to address this issue, but the underlying deadlock persists
> under extreme conditions.
>
> Any feedback on this new appock is welcome.
>
> Testing was done using v4l2-compliance and active decoding pipelines
> on Meson platforms (like Hardkernel ODROID-N2+ and ODROID-C4) SBCs.
>
> The v4l2-compliance tests passed successfully via:
> $ v4l2-compliance -s -v -d /dev/video0
>
> Pipelines were validated using the following GStreamer script.
>
> [1] https://gist.github.com/moonlinux/08295ba1f17ce7155550773f2d2cb6e5
>
> Previous changes:
> v6: https://lore.kernel.org/all/20260530094326.11892-2-linux.amoon@xxxxxxxxx/
>
I will review Sashiko's feedback. I will look into these suggestions and
work on incorporating them to improve the code quality
> Thanks
> -Annad
>
Thanks
-Anand