iommu/vt-d: Initialize prq_complete before requesting PRQ IRQ
Subsystems (3)
PATCH 1/1 iommu/vt-d: Initialize prq_complete before requesting PRQ IRQ
In intel_iommu_enable_prq(), request_threaded_irq() is called before init_completion(&iommu->prq_complete). The interrupt thread prq_event_thread() invokes complete(&iommu->prq_complete) upon receiving events. If an interrupt fires immediately upon registration or after enabling PRQ in DMAR_PQA_REG, the thread can access an uninitialized completion structure.
Move init_completion(&iommu->prq_complete) before requesting the IRQ.
---
I am trying out new Clang static analysis checks for kernel bug classes, and they flagged this code as possibly buggy. The findings were triaged/fixed and commit descriptions were drafted with help of AI, then checked against linux-next (not runtime-tested on hardware).
Thanks,
Elkin
drivers/iommu/intel/prq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iommu/intel/prq.c +2 -2
@@ -318,6 +318,8 @@ int intel_iommu_enable_prq(struct intel_iommu *iommu)snprintf (iommu->prq_name,sizeof (iommu->prq_name),"dmar%d-prq" , iommu->seq_id); +init_completion (&iommu->prq_complete); + ret =request_threaded_irq (irq,NULL , prq_event_thread,IRQF_ONESHOT , iommu->prq_name, iommu);if (ret) {
@@ -329,8 +331,6 @@ int intel_iommu_enable_prq(struct intel_iommu *iommu)writeq (0ULL , iommu->reg +DMAR_PQT_REG );writeq (virt_to_phys (iommu->prq) |PRQ_ORDER , iommu->reg +DMAR_PQA_REG ); -init_completion (&iommu->prq_complete); -return 0 ; free_iopfq:
Signature · 1 line
2.56.1.839.g22a8290db9-goog