FAILED: patch "[PATCH] media: mediatek: jpeg: Avoid context access after job finish" failed to apply to 5.15-stable tree
Subsystems (4)
Sasha Levin
maintainerThe patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x 7c7f31405b76acd95a628c834ee8a2d6da439782
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '[email protected]' --subject-prefix 'PATCH 5.15.y' 'HEAD^..'
Thanks,
Sasha
------------------ original commit in Linus's tree ------------------
From 7c7f31405b76acd95a628c834ee8a2d6da439782 Mon Sep 17 00:00:00 2001
From: Kazuki Hanai <[email protected]>
Date: Wed, 2 Sep 2026 20:22:28 +0900
Subject: [PATCH] media: mediatek: jpeg: Avoid context access after job finish
v4l2_m2m_job_finish() publishes job completion and wakes waiters before it returns. A concurrent file release can therefore finish v4l2_m2m_ctx_release() and free the context while the single-core IRQ handler continues with its tail.
Both handlers only need the device for the matching runtime PM put. Use the IRQ-owned jpeg pointer instead of dereferencing ctx after completion has been published. This preserves the get/put pairing and removes the post-completion context access.
--- drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c +2 -2
@@ -1574,7 +1574,7 @@ static irqreturn_t mtk_jpeg_enc_done(struct mtk_jpeg_dev *jpeg)v4l2_m2m_buf_done (src_buf, buf_state);v4l2_m2m_buf_done (dst_buf, buf_state);v4l2_m2m_job_finish (jpeg->m2m_dev, ctx->fh.m2m_ctx); -pm_runtime_put (ctx->jpeg->dev); +pm_runtime_put (jpeg->dev);return IRQ_HANDLED ; }
@@ -1856,7 +1856,7 @@ static irqreturn_t mtk_jpeg_dec_irq(int irq, void *priv)v4l2_m2m_buf_done (src_buf, buf_state);v4l2_m2m_buf_done (dst_buf, buf_state);v4l2_m2m_job_finish (jpeg->m2m_dev, ctx->fh.m2m_ctx); -pm_runtime_put (ctx->jpeg->dev); +pm_runtime_put (jpeg->dev);return IRQ_HANDLED ; }
Signature · 1 line
2.53.0