From: "Shengzhuo Wei" <me@cherr.cc>
To: "Mirela Rabulea" <mirela.rabulea@nxp.com>,
"Mauro Carvalho Chehab" <mchehab@kernel.org>,
"Frank Li" <Frank.Li@nxp.com>,
"Sascha Hauer" <s.hauer@pengutronix.de>,
"Pengutronix Kernel Team" <kernel@pengutronix.de>,
"Fabio Estevam" <festevam@gmail.com>,
"Hans Verkuil" <hverkuil@kernel.org>,
"Ming Qian" <ming.qian@nxp.com>,
"Nicolas Dufresne" <nicolas.dufresne@collabora.com>,
"Benjamin Gaignard" <benjamin.gaignard@collabora.com>,
"Philipp Zabel" <p.zabel@pengutronix.de>,
"Ezequiel Garcia" <ezequiel@vanguardiasur.com.ar>,
"Bin Liu" <bin.liu@mediatek.com>,
"Matthias Brugger" <matthias.bgg@gmail.com>,
"AngeloGioacchino Del Regno"
<angelogioacchino.delregno@collabora.com>,
"irui wang" <irui.wang@mediatek.com>,
"kyrie wu" <kyrie.wu@mediatek.com>
Cc: <imx@lists.linux.dev>, <linux-media@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>, <stable@vger.kernel.org>,
"Shengzhuo Wei" <me@cherr.cc>
Subject: [PATCH 1/3] media: nxp: imx-jpeg: cancel task_timer before freeing ctx
Date: Tue, 25 Aug 2026 03:34:30 +0800 [thread overview]
Message-ID: <20260825-media-timeout-work-v1-1-ebfebbeb6c31@cherr.cc> (raw)
In-Reply-To: <20260825-media-timeout-work-v1-0-ebfebbeb6c31@cherr.cc>
mxc_jpeg_device_run() arms ctx->task_timer for each job; the only place
it is cancelled is the job-completion IRQ handler. If the hardware
never completes the job, mxc_jpeg_release() frees ctx with the timer
still pending, and mxc_jpeg_device_run_timeout() then dereferences the
freed ctx -- a use-after-free.
Cancel the timer before the ctx is torn down, before taking
mxc_jpeg->lock so the cancel never waits on a worker that needs the
mutex.
Fixes: cfed9632ca8e ("media: imx-jpeg: Add a timeout mechanism for each frame")
Cc: stable@vger.kernel.org
Signed-off-by: Shengzhuo Wei <me@cherr.cc>
Assisted-by: GLM:5.3
---
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
index 725e941528848e8f224fe6a96ba7f746fc45ed63..fbb64a1ecb5189d2d7b953b99dcd7bcb54e6e20e 100644
--- a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
+++ b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c
@@ -2796,6 +2796,8 @@ static int mxc_jpeg_release(struct file *file)
struct mxc_jpeg_ctx *ctx = mxc_jpeg_file_to_ctx(file);
struct device *dev = mxc_jpeg->dev;
+ cancel_delayed_work_sync(&ctx->task_timer);
+
mutex_lock(&mxc_jpeg->lock);
if (mxc_jpeg->mode == MXC_JPEG_DECODE)
dev_dbg(dev, "Release JPEG decoder instance on slot %d.",
--
2.47.3
next prev parent reply other threads:[~2026-08-24 19:34 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-24 19:34 [PATCH 0/3] media: cancel timeout delayed work before freeing its owner Shengzhuo Wei
2026-08-24 19:34 ` Shengzhuo Wei [this message]
2026-08-24 19:48 ` [PATCH 1/3] media: nxp: imx-jpeg: cancel task_timer before freeing ctx sashiko-bot
2026-08-25 1:56 ` Ming Qian(OSS)
2026-08-25 3:39 ` Shengzhuo Wei
2026-08-24 19:34 ` [PATCH 2/3] media: verisilicon: hantro: cancel watchdog work before m2m release Shengzhuo Wei
2026-08-24 19:49 ` sashiko-bot
2026-09-14 19:35 ` Frank Li
2026-08-24 19:34 ` [PATCH 3/3] media: mediatek: jpeg: cancel job timeout " Shengzhuo Wei
2026-08-24 19:49 ` 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=20260825-media-timeout-work-v1-1-ebfebbeb6c31@cherr.cc \
--to=me@cherr.cc \
--cc=Frank.Li@nxp.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=benjamin.gaignard@collabora.com \
--cc=bin.liu@mediatek.com \
--cc=ezequiel@vanguardiasur.com.ar \
--cc=festevam@gmail.com \
--cc=hverkuil@kernel.org \
--cc=imx@lists.linux.dev \
--cc=irui.wang@mediatek.com \
--cc=kernel@pengutronix.de \
--cc=kyrie.wu@mediatek.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-media@vger.kernel.org \
--cc=matthias.bgg@gmail.com \
--cc=mchehab@kernel.org \
--cc=ming.qian@nxp.com \
--cc=mirela.rabulea@nxp.com \
--cc=nicolas.dufresne@collabora.com \
--cc=p.zabel@pengutronix.de \
--cc=s.hauer@pengutronix.de \
--cc=stable@vger.kernel.org \
/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.