* [PATCH v5 0/2] media: venus: fix HFI teardown races
@ 2026-10-24 2:40 Myeonghun Pak
2026-10-24 2:40 ` [PATCH v5 1/2] media: venus: hfi: disable IRQ before freeing HFI device Myeonghun Pak
2026-10-24 2:40 ` [PATCH v5 2/2] media: venus: disable recovery work before HFI teardown Myeonghun Pak
0 siblings, 2 replies; 3+ messages in thread
From: Myeonghun Pak @ 2026-10-24 2:40 UTC (permalink / raw)
To: Vikash Garodia, Dikshita Agarwal
Cc: Bryan O'Donoghue, Mauro Carvalho Chehab, linux-media,
linux-arm-msm, linux-kernel, Sashiko, stable, Ijae Kim
This issue was identified as part of our ongoing research while
reviewing kernel code.
Synchronize IRQ handlers before freeing HFI state, and disable recovery
work at the start of remove to prevent it from racing with teardown.
Changes in v5:
- Patch 1: no code changes; carry Bryan's Reviewed-by.
- Patch 2: drop the duplicate work disable from venus_hfi_destroy(),
keeping it only in venus_remove(), as requested by Bryan.
- Rebase onto media-committers.git next.
Compilation test completed.
v4: https://lore.kernel.org/all/20261001175502.4045853-1-mhun512@gmail.com/
Myeonghun Pak (2):
media: venus: hfi: disable IRQ before freeing HFI device
media: venus: disable recovery work before HFI teardown
drivers/media/platform/qcom/venus/core.c | 2 +-
drivers/media/platform/qcom/venus/hfi_venus.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
base-commit: d7e7bca7169873b46e857c025c10f3336c1258d8
--
2.53.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v5 1/2] media: venus: hfi: disable IRQ before freeing HFI device
2026-10-24 2:40 [PATCH v5 0/2] media: venus: fix HFI teardown races Myeonghun Pak
@ 2026-10-24 2:40 ` Myeonghun Pak
2026-10-24 2:40 ` [PATCH v5 2/2] media: venus: disable recovery work before HFI teardown Myeonghun Pak
1 sibling, 0 replies; 3+ messages in thread
From: Myeonghun Pak @ 2026-10-24 2:40 UTC (permalink / raw)
To: Vikash Garodia, Dikshita Agarwal
Cc: Bryan O'Donoghue, Mauro Carvalho Chehab, linux-media,
linux-arm-msm, linux-kernel, Sashiko, stable, Ijae Kim,
Bryan O'Donoghue
venus_hfi_destroy() frees hdev and its interface queues before disabling
the IRQ. A handler that already loaded core->priv can therefore access
freed state even after core->priv is cleared.
Move disable_irq() before clearing core->priv and releasing HFI state so
both the hard and threaded handlers have completed before teardown.
Fixes: d96d3f30c0f2 ("[media] media: venus: hfi: add Venus HFI files")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://lore.kernel.org/all/20260612103333.5585D1F000E9@smtp.kernel.org/
Cc: stable@vger.kernel.org
Assisted-by: LLM
Co-developed-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
---
drivers/media/platform/qcom/venus/hfi_venus.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c
index bd82066bb6e77f68ac3fe1440a8b5429ad62a192..e7e4e78a186adaa7fd80deeb094ed53d54f27ba6 100644
--- a/drivers/media/platform/qcom/venus/hfi_venus.c
+++ b/drivers/media/platform/qcom/venus/hfi_venus.c
@@ -1689,11 +1689,11 @@ void venus_hfi_destroy(struct venus_core *core)
{
struct venus_hfi_device *hdev = to_hfi_priv(core);
+ disable_irq(core->irq);
core->priv = NULL;
venus_interface_queues_release(hdev);
mutex_destroy(&hdev->lock);
kfree(hdev);
- disable_irq(core->irq);
core->ops = NULL;
}
--
2.53.0
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH v5 2/2] media: venus: disable recovery work before HFI teardown
2026-10-24 2:40 [PATCH v5 0/2] media: venus: fix HFI teardown races Myeonghun Pak
2026-10-24 2:40 ` [PATCH v5 1/2] media: venus: hfi: disable IRQ before freeing HFI device Myeonghun Pak
@ 2026-10-24 2:40 ` Myeonghun Pak
1 sibling, 0 replies; 3+ messages in thread
From: Myeonghun Pak @ 2026-10-24 2:40 UTC (permalink / raw)
To: Vikash Garodia, Dikshita Agarwal
Cc: Bryan O'Donoghue, Mauro Carvalho Chehab, linux-media,
linux-arm-msm, linux-kernel, Sashiko, stable, Ijae Kim
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")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://lore.kernel.org/all/20260730153912.BAC5E1F00A3D@smtp.kernel.org/
Cc: stable@vger.kernel.org
Assisted-by: LLM
Co-developed-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
---
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-24 2:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-24 2:40 [PATCH v5 0/2] media: venus: fix HFI teardown races Myeonghun Pak
2026-10-24 2:40 ` [PATCH v5 1/2] media: venus: hfi: disable IRQ before freeing HFI device Myeonghun Pak
2026-10-24 2:40 ` [PATCH v5 2/2] media: venus: disable recovery work before HFI teardown Myeonghun Pak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®