提交 6927d352 编写于 作者: Y Yang Yingliang 提交者: Joerg Roedel

iommu/vt-d: Fix PCI device refcount leak in prq_event_thread()

As comment of pci_get_domain_bus_and_slot() says, it returns a pci device
with refcount increment, when finish using it, the caller must decrease
the reference count by calling pci_dev_put(). So call pci_dev_put() after
using the 'pdev' to avoid refcount leak.

Besides, if the 'pdev' is null or intel_svm_prq_report() returns error,
there is no need to trace this fault.

Fixes: 06f4b8d0 ("iommu/vt-d: Remove unnecessary SVA data accesses in page fault path")
Suggested-by: NLu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20221119144028.2452731-1-yangyingliang@huawei.comSigned-off-by: NLu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: NJoerg Roedel <jroedel@suse.de>
上级 e65a6897
...@@ -748,12 +748,16 @@ static irqreturn_t prq_event_thread(int irq, void *d) ...@@ -748,12 +748,16 @@ static irqreturn_t prq_event_thread(int irq, void *d)
* If prq is to be handled outside iommu driver via receiver of * If prq is to be handled outside iommu driver via receiver of
* the fault notifiers, we skip the page response here. * the fault notifiers, we skip the page response here.
*/ */
if (!pdev || intel_svm_prq_report(iommu, &pdev->dev, req)) if (!pdev)
handle_bad_prq_event(iommu, req, QI_RESP_INVALID); goto bad_req;
trace_prq_report(iommu, &pdev->dev, req->qw_0, req->qw_1, if (intel_svm_prq_report(iommu, &pdev->dev, req))
req->priv_data[0], req->priv_data[1], handle_bad_prq_event(iommu, req, QI_RESP_INVALID);
iommu->prq_seq_number++); else
trace_prq_report(iommu, &pdev->dev, req->qw_0, req->qw_1,
req->priv_data[0], req->priv_data[1],
iommu->prq_seq_number++);
pci_dev_put(pdev);
prq_advance: prq_advance:
head = (head + sizeof(*req)) & PRQ_RING_MASK; head = (head + sizeof(*req)) & PRQ_RING_MASK;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册