mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ruoyu Wang <ruoyuw560@gmail.com>
To: Joerg Roedel <joro@8bytes.org>,
	Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
	Will Deacon <will@kernel.org>,
	Robin Murphy <robin.murphy@arm.com>,
	Jason Gunthorpe <jgg@ziepe.ca>, Wei Huang <wei.huang2@amd.com>,
	Vasant Hegde <vasant.hegde@amd.com>
Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
	Ruoyu Wang <ruoyuw560@gmail.com>
Subject: [PATCH] iommu/amd: Fix PCI device reference leak in PPR handling
Date: Fri, 14 Aug 2026 21:39:38 +0800	[thread overview]
Message-ID: <20260814133938.1385879-1-ruoyuw560@gmail.com> (raw)

pci_get_domain_bus_and_slot() takes a reference on the returned PCI
device. iommu_call_iopf_notifier() fails to release it after either
reporting a valid PPR fault or completing a rejected request. Each
handled request therefore leaks a reference and can prevent the PCI
device from being released.

Call pci_dev_put() after the final use of the lookup reference on both
paths.

This issue was found by a static analysis checker and confirmed by
manual source review.

Fixes: 978d626b8f1a ("iommu/amd: Add IO page fault notifier handler")
Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
---
 drivers/iommu/amd/ppr.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/iommu/amd/ppr.c b/drivers/iommu/amd/ppr.c
index 1f8d2823bea42..1e4392b17bd8f 100644
--- a/drivers/iommu/amd/ppr.c
+++ b/drivers/iommu/amd/ppr.c
@@ -151,6 +151,7 @@ static void iommu_call_iopf_notifier(struct amd_iommu *iommu, u64 *raw)
 
 	/* Submit event */
 	iommu_report_device_fault(&pdev->dev, &event);
+	pci_dev_put(pdev);
 
 	return;
 
@@ -159,6 +160,7 @@ static void iommu_call_iopf_notifier(struct amd_iommu *iommu, u64 *raw)
 	amd_iommu_complete_ppr(&pdev->dev, PPR_PASID(raw[0]),
 			       IOMMU_PAGE_RESP_FAILURE,
 			       PPR_TAG(raw[0]) & 0x1FF);
+	pci_dev_put(pdev);
 }
 
 void amd_iommu_poll_ppr_log(struct amd_iommu *iommu)
-- 
2.51.0


             reply	other threads:[~2026-08-14 13:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-14 13:39 Ruoyu Wang [this message]
2026-08-16 14:48 ` Markus Elfring
2026-08-22 14:09 ` Vasant Hegde
2026-08-23  6:20   ` Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260814133938.1385879-1-ruoyuw560@gmail.com \
    --to=ruoyuw560@gmail.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@ziepe.ca \
    --cc=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=vasant.hegde@amd.com \
    --cc=wei.huang2@amd.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®