Re: [PATCH v5 2/2] media: venus: disable recovery work before HFI teardown

From: bod

Date: Tue Nov 17 2026 - 06:21:04 EST


On 2026-10-23 22:40 -0400, Myeonghun Pak wrote:
> venus_remove() cancels core->work while the IRQ can still schedule it.
> A later IRQ can requeue recovery work, which may access HFI state after
> it has been freed.
>
> Use disable_delayed_work_sync() at the start of remove to drain recovery
> and prevent further IRQ or worker requeues. Drain the work before
> disabling the IRQ so recovery can finish completion waits that depend
> on IRQs.
>
> Fixes: af2c3834c8ca ("[media] media: venus: adding core part and helper functions")

Fixes: c5a85ed88e04 ("media: venus: fix use after free bug in venus_remove due to race condition")

Don't resend I'll fix the tag for you.

> Reported-by: Sashiko <sashiko-bot@xxxxxxxxxx>
> Link: https://lore.kernel.org/all/20260730153912.BAC5E1F00A3D@xxxxxxxxxxxxxxx/
> Cc: stable@xxxxxxxxxxxxxxx
> Assisted-by: LLM
> Co-developed-by: Ijae Kim <ae878000@xxxxxxxxx>
> Signed-off-by: Ijae Kim <ae878000@xxxxxxxxx>
> Signed-off-by: Myeonghun Pak <mhun512@xxxxxxxxx>
> ---
> drivers/media/platform/qcom/venus/core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c
> index 7087af32060f1ed4190bf9f5d4a58cf88dad537d..6e495bc046913b46c926a498c062a6b55c6f7b64 100644
> --- a/drivers/media/platform/qcom/venus/core.c
> +++ b/drivers/media/platform/qcom/venus/core.c
> @@ -596,7 +596,7 @@ static void venus_remove(struct platform_device *pdev)
> struct device *dev = core->dev;
> int ret;
>
> - cancel_delayed_work_sync(&core->work);
> + disable_delayed_work_sync(&core->work);
> ret = pm_runtime_get_sync(dev);
> WARN_ON(ret < 0);
>
> --
> 2.53.0
>
>
>

Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@xxxxxxxxxx>
---
bod