Linux Media Controller development
 help / color / mirror / Atom feed
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 2/3] media: verisilicon: hantro: cancel watchdog work before m2m release
Date: Tue, 25 Aug 2026 03:34:31 +0800	[thread overview]
Message-ID: <20260825-media-timeout-work-v1-2-ebfebbeb6c31@cherr.cc> (raw)
In-Reply-To: <20260825-media-timeout-work-v1-0-ebfebbeb6c31@cherr.cc>

Each job arms vpu->watchdog_work, cancelled only by the
job-completion path. If a job stalls, hantro_remove() drops the last
reference to vpu->m2m_dev via v4l2_m2m_put() with the watchdog still
pending, and hantro_watchdog() then dereferences the freed m2m_dev --
a use-after-free.

Drain the watchdog before the m2m device is released.

Fixes: 775fec69008d ("media: add Rockchip VPU JPEG encoder driver")
Cc: stable@vger.kernel.org
Signed-off-by: Shengzhuo Wei <me@cherr.cc>
Assisted-by: GLM:5.3
---
 drivers/media/platform/verisilicon/hantro_drv.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
index 2e81877f640fb429b18d2f4fd64bc0c392cf600e..1b04b98371a48184f390a13791243fd00d6b80ef 100644
--- a/drivers/media/platform/verisilicon/hantro_drv.c
+++ b/drivers/media/platform/verisilicon/hantro_drv.c
@@ -1284,6 +1284,7 @@ static void hantro_remove(struct platform_device *pdev)
 	hantro_remove_dec_func(vpu);
 	hantro_remove_enc_func(vpu);
 	media_device_cleanup(&vpu->mdev);
+	cancel_delayed_work_sync(&vpu->watchdog_work);
 	v4l2_m2m_put(vpu->m2m_dev);
 	v4l2_device_unregister(&vpu->v4l2_dev);
 	clk_bulk_unprepare(vpu->variant->num_clocks, vpu->clocks);

-- 
2.47.3

  parent reply	other threads:[~2026-08-24 19:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260825-media-timeout-work-v1-0-ebfebbeb6c31@cherr.cc>
2026-08-24 19:34 ` [PATCH 1/3] media: nxp: imx-jpeg: cancel task_timer before freeing ctx Shengzhuo Wei
2026-08-25  1:56   ` Ming Qian(OSS)
2026-08-25  3:39     ` Shengzhuo Wei
2026-08-24 19:34 ` Shengzhuo Wei [this message]
2026-08-24 19:34 ` [PATCH 3/3] media: mediatek: jpeg: cancel job timeout work before m2m release Shengzhuo Wei

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-2-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox