* [PATCH 0/2] media: venus: fix HFI teardown races
@ 2026-09-25 0:09 mhun512
2026-09-25 0:09 ` [PATCH 1/2] media: venus: hfi: disable IRQ before freeing HFI device mhun512
2026-09-25 0:09 ` [PATCH 2/2] media: venus: disable recovery work before HFI teardown mhun512
0 siblings, 2 replies; 3+ messages in thread
From: mhun512 @ 2026-09-25 0:09 UTC (permalink / raw)
To: vikash.garodia, dikshita.agarwal
Cc: bod, mchehab, linux-media, linux-arm-msm, linux-kernel, mhun512
As part of our ongoing static-analysis research, we reviewed the Venus
teardown path and confirmed the race reported by Sashiko.
This series fixes two HFI lifetime races during teardown. The first patch
waits for the hard and threaded IRQ handlers before releasing HFI state.
The second disables and drains recovery work so it cannot be requeued
while HFI state is being torn down.
The later Sashiko report also identifies a separate resource leak when IRQ
registration fails during probe. That issue is outside this series.
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 | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
--
2.53.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] media: venus: hfi: disable IRQ before freeing HFI device
2026-09-25 0:09 [PATCH 0/2] media: venus: fix HFI teardown races mhun512
@ 2026-09-25 0:09 ` mhun512
2026-09-25 0:09 ` [PATCH 2/2] media: venus: disable recovery work before HFI teardown mhun512
1 sibling, 0 replies; 3+ messages in thread
From: mhun512 @ 2026-09-25 0:09 UTC (permalink / raw)
To: vikash.garodia, dikshita.agarwal
Cc: bod, mchehab, linux-media, linux-arm-msm, linux-kernel, mhun512,
sashiko-bot, stable, ae878000
venus_hfi_destroy() releases the interface queues and frees hdev before
calling disable_irq(). An IRQ handler that has already read core->priv
can continue to access hdev and its queues after they are freed. Clearing
core->priv does not revoke the handler's local pointer.
Commit 640803003cd9 ("media: venus: hfi: explicitly release IRQ during
teardown") added disable_irq(), but placed it after kfree(hdev), too late
to protect a handler already using hdev.
Disable the IRQ first so that both the hard IRQ and threaded handler have
completed before clearing core->priv or releasing hdev.
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>
---
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 bd82066bb6e7..e7e4e78a186a 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
On Fri, 25 Sep 2026 00:09:06 +0000, mhun512@gmail.com wrote:
> As part of our ongoing static-analysis research, we reviewed the Venus
> teardown path and confirmed the race reported by Sashiko.
>
> This series fixes two HFI lifetime races during teardown. The first patch
> waits for the hard and threaded IRQ handlers before releasing HFI state.
> The second disables and drains recovery work so it cannot be requeued
> while HFI state is being torn down.
>
> The later Sashiko report also identifies a separate resource leak when IRQ
> registration fails during probe. That issue is outside this series.
>
> 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 | 3 ++-
> 2 files changed, 3 insertions(+), 2 deletions(-)
>
> --
> 2.53.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] media: venus: disable recovery work before HFI teardown
2026-09-25 0:09 [PATCH 0/2] media: venus: fix HFI teardown races mhun512
2026-09-25 0:09 ` [PATCH 1/2] media: venus: hfi: disable IRQ before freeing HFI device mhun512
@ 2026-09-25 0:09 ` mhun512
1 sibling, 0 replies; 3+ messages in thread
From: mhun512 @ 2026-09-25 0:09 UTC (permalink / raw)
To: vikash.garodia, dikshita.agarwal
Cc: bod, mchehab, linux-media, linux-arm-msm, linux-kernel, mhun512,
sashiko-bot, stable, ae878000
venus_remove() cancels core->work before the IRQ is disabled. An IRQ
thread can queue the work again after cancellation. The work can then
access HFI state after venus_hfi_destroy() frees it. The work also
requeues itself when recovery fails, so cancelling an already running
instance alone does not close the race.
Disable and drain the work at the start of remove, before other resources
are dismantled. Do the same in venus_hfi_destroy() for paths that bypass
remove, including probe unwind. Disabling the work prevents both IRQ
handlers and the work itself from requeuing it. Drain the work before
disabling the IRQ so an active recovery can finish any IRQ based
completion waits. Then synchronize the IRQ before freeing HFI state.
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 +-
drivers/media/platform/qcom/venus/hfi_venus.c | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/qcom/venus/core.c
b/drivers/media/platform/qcom/venus/core.c
index 243e342b0ae7..94d4b8688ac2 100644
--- a/drivers/media/platform/qcom/venus/core.c
+++ b/drivers/media/platform/qcom/venus/core.c
@@ -538,7 +538,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);
diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c
b/drivers/media/platform/qcom/venus/hfi_venus.c
index e7e4e78a186a..20b8ba1e62f1 100644
--- a/drivers/media/platform/qcom/venus/hfi_venus.c
+++ b/drivers/media/platform/qcom/venus/hfi_venus.c
@@ -1689,6 +1689,7 @@ void venus_hfi_destroy(struct venus_core *core)
{
struct venus_hfi_device *hdev = to_hfi_priv(core);
+ disable_delayed_work_sync(&core->work);
disable_irq(core->irq);
core->priv = NULL;
venus_interface_queues_release(hdev);
--
2.53.0
On Fri, 25 Sep 2026 00:09:06 +0000, mhun512@gmail.com wrote:
> As part of our ongoing static-analysis research, we reviewed the Venus
> teardown path and confirmed the race reported by Sashiko.
>
> This series fixes two HFI lifetime races during teardown. The first patch
> waits for the hard and threaded IRQ handlers before releasing HFI state.
> The second disables and drains recovery work so it cannot be requeued
> while HFI state is being torn down.
>
> The later Sashiko report also identifies a separate resource leak when IRQ
> registration fails during probe. That issue is outside this series.
>
> 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 | 3 ++-
> 2 files changed, 3 insertions(+), 2 deletions(-)
>
> --
> 2.53.0
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-25 0:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-25 0:09 [PATCH 0/2] media: venus: fix HFI teardown races mhun512
2026-09-25 0:09 ` [PATCH 1/2] media: venus: hfi: disable IRQ before freeing HFI device mhun512
2026-09-25 0:09 ` [PATCH 2/2] media: venus: disable recovery work before HFI teardown mhun512
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®