Skip to content

media: cancel timeout delayed work before freeing its owner

Shengzhuo Wei imx linux-arm-kernel linux-media stable 1 version In review

Get series with b4
b4 am [email protected] change-id 20260825-media-timeout-work-1cef7720c63b

Versions newest first

  1. v1 Latest3 patches 5 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3media: nxp: imx-jpeg: cancel task_timer before freeing ctxdrivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c+2 -02 replies
2/3media: verisilicon: hantro: cancel watchdog work before m2m releasedrivers/media/platform/verisilicon/hantro_drv.c+1 -02 replies
3/3media: mediatek: jpeg: cancel job timeout work before m2m releasedrivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c+1 -01 reply

Reviews trailers per patch

1 of 3 patches has a Reviewed-by or Acked-by.

PatchFrank Li
1/3
2/3R-b
3/3

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/3] media: cancel timeout delayed work before freeing its owner

Three m2m codec drivers arm a per-job timeout delayed work on the system workqueue and only cancel it on the job-completion path. If the hardware never completes the job, the release/remove path frees the object the timeout callback dereferences (via container_of or through the m2m device) with the work still pending -- a use-after-free when the timer expires.

All three are the same missed-twins class as the recent mtk-jpeg jpeg_work release fix and the host1x timeout-worker fix. In each case the fix is a single cancel_delayed_work_sync() placed before the object is freed:

- mxc-jpeg: cancel ctx->task_timer in mxc_jpeg_release() before kfree(ctx); the timer is otherwise only cancelled in the job IRQ.
- hantro: cancel vpu->watchdog_work in hantro_remove() before v4l2_m2m_put() frees the m2m device the watchdog dereferences.
- mtk-jpeg: cancel jpeg->job_timeout_work in mtk_jpeg_remove() before v4l2_m2m_release(); ctx->jpeg_work in the same driver got the equivalent fix earlier, the device-level work was missed.

Patches are independent of each other.

---
Shengzhuo Wei (3):
media: nxp: imx-jpeg: cancel task_timer before freeing ctx
media: verisilicon: hantro: cancel watchdog work before m2m release
media: mediatek: jpeg: cancel job timeout work before m2m release

 drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c | 1 +
 drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c       | 2 ++
 drivers/media/platform/verisilicon/hantro_drv.c      | 1 +
 3 files changed, 4 insertions(+)

---
base-commit: 075b74841bd0065a3bda3440873c747938e69b68
change-id: 20260825-media-timeout-work-1cef7720c63b

Best regards,

Signature · 1 line
Shengzhuo Wei <[email protected]>