[PATCH] media: mediatek: vpu: free IRQ before destroying watchdog workqueue

Nicolas Dufresne nicolas at ndufresne.ca
Tue Sep 29 13:00:36 PDT 2026


Le mercredi 23 septembre 2026 à 08:59 +0000, Fan Wu a écrit :
> mtk_vpu_remove() destroys the watchdog workqueue while the interrupt
> handler requested with devm_request_irq() is still registered: the
> devres core frees the interrupt only after remove() has returned. If
> the VPU watchdog fires in that window, vpu_irq_handler() queues
> vpu->wdt.ws on the already destroyed vpu->wdt.wq.
> 
> Fix this by calling devm_free_irq() before destroy_workqueue(), which
> releases the interrupt and waits for a running handler, so no new work
> can be queued while the workqueue is drained and freed.
> 
> This issue was found by an in-house static analysis tool.
> 
> Fixes: 3003a180ef6b ("[media] VPU: mediatek: support Mediatek VPU")
> Cc: stable at vger.kernel.org
> Co-developed-by: Song Li <songl at zju.edu.cn>
> Signed-off-by: Song Li <songl at zju.edu.cn>
> Signed-off-by: Fan Wu <fanwu01 at zju.edu.cn>

Reviewed-by: Nicolas Dufresne <nicolas.dufres at collabora.com>

> ---
>  drivers/media/platform/mediatek/vpu/mtk_vpu.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/media/platform/mediatek/vpu/mtk_vpu.c b/drivers/media/platform/mediatek/vpu/mtk_vpu.c
> index 8d8319f..b6bd80b 100644
> --- a/drivers/media/platform/mediatek/vpu/mtk_vpu.c
> +++ b/drivers/media/platform/mediatek/vpu/mtk_vpu.c
> @@ -962,6 +962,7 @@ static void mtk_vpu_remove(struct platform_device *pdev)
>  #ifdef CONFIG_DEBUG_FS
>  	debugfs_remove(vpu_debugfs);
>  #endif
> +	devm_free_irq(&pdev->dev, vpu->reg.irq, vpu);

On the clean factor, it reduce the use of devm API here, but the error path in
probe relies on it still.

>  	if (vpu->wdt.wq)
>  		destroy_workqueue(vpu->wdt.wq);
>  	vpu_free_ext_mem(vpu, P_FW);
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-mediatek/attachments/20260929/c506ae2c/attachment.sig>


More information about the Linux-mediatek mailing list