[PATCH] media: venus: Fix potential HFI leak on IRQ request failure
From: Guangshuo Li
Date: Thu Nov 12 2026 - 09:11:38 EST
HFI creation now precedes the IRQ request. If that request fails, probe
skips hfi_destroy() and leaks the HFI state and interface queues.
Unwind HFI on this path. Move IRQ disabling to the callers so teardown
does not disable an IRQ that was never requested, and synchronize a
registered IRQ before freeing the state used by its handler.
This issue was found by our static analysis tool under development.
Fixes: 3200144a2fa4 ("media: venus: protect against spurious interrupts during probe")
Signed-off-by: Guangshuo Li <liguangshuo@xxxxxxxxxxxxxxx>
---
drivers/media/platform/qcom/venus/core.c | 7 +++++--
drivers/media/platform/qcom/venus/hfi_venus.c | 1 -
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c
index 7087af32060f..6a429ed17c47 100644
--- a/drivers/media/platform/qcom/venus/core.c
+++ b/drivers/media/platform/qcom/venus/core.c
@@ -496,13 +496,13 @@ static int venus_probe(struct platform_device *pdev)
IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
"venus", core);
if (ret)
- goto err_unresv_iova_region;
+ goto err_hfi_destroy;
venus_assign_register_offsets(core);
ret = v4l2_device_register(dev, &core->v4l2_dev);
if (ret)
- goto err_hfi_destroy;
+ goto err_disable_irq;
platform_set_drvdata(pdev, core);
@@ -579,6 +579,8 @@ static int venus_probe(struct platform_device *pdev)
pm_runtime_disable(dev);
pm_runtime_set_suspended(dev);
v4l2_device_unregister(&core->v4l2_dev);
+err_disable_irq:
+ disable_irq(core->irq);
err_hfi_destroy:
hfi_destroy(core);
err_unresv_iova_region:
@@ -618,6 +620,7 @@ static void venus_remove(struct platform_device *pdev)
v4l2_device_unregister(&core->v4l2_dev);
+ disable_irq(core->irq);
hfi_destroy(core);
venus_unreserve_iova_region(dev, core->iova_state);
diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c
index bd82066bb6e7..20e2494697fa 100644
--- a/drivers/media/platform/qcom/venus/hfi_venus.c
+++ b/drivers/media/platform/qcom/venus/hfi_venus.c
@@ -1693,7 +1693,6 @@ void venus_hfi_destroy(struct venus_core *core)
venus_interface_queues_release(hdev);
mutex_destroy(&hdev->lock);
kfree(hdev);
- disable_irq(core->irq);
core->ops = NULL;
}
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4