From: Shuai Xue <xueshuai@linux.alibaba.com>
To: Ruoyu Wang <ruoyuw560@gmail.com>,
Jing Zhang <renyu.zj@linux.alibaba.com>,
Will Deacon <will@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Yunhui Cui <cuiyunhui@bytedance.com>
Cc: linux-arm-kernel@lists.infradead.org,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf/dwc_pcie: Fix PCI device reference leak in probe
Date: Sun, 16 Aug 2026 09:42:36 +0800 [thread overview]
Message-ID: <7321c855-08b7-4270-9d98-297a872ad47d@linux.alibaba.com> (raw)
In-Reply-To: <20260814133925.1385687-1-ruoyuw560@gmail.com>
On 8/14/26 9:39 PM, Ruoyu Wang wrote:
> pci_get_domain_bus_and_slot() returns a referenced PCI device. When the
> subsequent RAS DES capability lookup fails, dwc_pcie_pmu_probe() returns
> -ENODEV without releasing that reference. Repeated failed probes can
> therefore keep the PCI device allocated after removal.
>
> Move the existing pci_dev_put() immediately after capability discovery
> so the temporary lookup reference is released on both success and
> failure paths.
>
> This issue was found by a static analysis checker and confirmed by
> manual source review.
>
> Fixes: 7f35b429802a ("perf/dwc_pcie: fix duplicate pci_dev devices")
> Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
> ---
> drivers/perf/dwc_pcie_pmu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/perf/dwc_pcie_pmu.c b/drivers/perf/dwc_pcie_pmu.c
> index 5385401fa9cf6..baa736fd9a6ef 100644
> --- a/drivers/perf/dwc_pcie_pmu.c
> +++ b/drivers/perf/dwc_pcie_pmu.c
> @@ -710,10 +710,10 @@ static int dwc_pcie_pmu_probe(struct platform_device *plat_dev)
> }
>
> vsec = dwc_pcie_des_cap(pdev);
> + pci_dev_put(pdev);
> if (!vsec)
> return -ENODEV;
>
> - pci_dev_put(pdev);
> name = devm_kasprintf(&plat_dev->dev, GFP_KERNEL, "dwc_rootport_%x", sbdf);
> if (!name)
> return -ENOMEM;
Good catch.
Reviewed-by: Shuai Xue <xueshuai@linux.alibaba.com>
Thanks.
Shuai
next prev parent reply other threads:[~2026-08-16 1:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-14 13:39 [PATCH] perf/dwc_pcie: Fix PCI device reference leak in probe Ruoyu Wang
2026-08-16 1:42 ` Shuai Xue [this message]
2026-08-16 8:26 ` 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=7321c855-08b7-4270-9d98-297a872ad47d@linux.alibaba.com \
--to=xueshuai@linux.alibaba.com \
--cc=cuiyunhui@bytedance.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=renyu.zj@linux.alibaba.com \
--cc=ruoyuw560@gmail.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