Linux Perf Users
 help / color / mirror / Atom feed
* [PATCH v2] x86/events/intel/uncore: fix PCI refcount leak in discover_upi_topology
@ 2026-06-28 11:17 WenTao Liang
  2026-06-29  2:32 ` Mi, Dapeng
  0 siblings, 1 reply; 2+ messages in thread
From: WenTao Liang @ 2026-06-28 11:17 UTC (permalink / raw)
  To: linux-perf-users
  Cc: peterz, mingo, acme, namhyung, mark.rutland, alexander.shishkin,
	jolsa, irogers, adrian.hunter, james.clark, tglx, bp, dave.hansen,
	x86, hpa, linux-kernel, stable, WenTao Liang, Greg KH

In the inner for loop, dev is repeatedly overwritten by
pci_get_domain_bus_and_slot() without first releasing the previous dev
via pci_dev_put(). The err label only releases the last ubox and dev
references, while the references from earlier loop iterations are
permanently leaked. Fix by adding pci_dev_put(dev) before the overwriting
assignment.

Suggested-by: Greg KH <gregkh@linuxfoundation.org>
Fixes: fdd041028f22 ("perf/x86/intel/uncore: Factor out topology_gidnid_map()")
Cc: stable@vger.kernel.org
Signed-off-by: WenTao Liang <vulab@iscas.ac.cn>
---
Changes in v2:
- Fix patch format based on reviewer feedback
---
---
 arch/x86/events/intel/uncore_snbep.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c
index 215d33e260ed..cecc1ce0a248 100644
--- a/arch/x86/events/intel/uncore_snbep.c
+++ b/arch/x86/events/intel/uncore_snbep.c
@@ -5494,6 +5494,7 @@ static int discover_upi_topology(struct intel_uncore_type *type, int ubox_did, i
 		for (idx = 0; idx < type->num_boxes; idx++) {
 			upi = &type->topology[lgc_pkg][idx];
 			devfn = PCI_DEVFN(dev_link0 + idx, ICX_UPI_REGS_ADDR_FUNCTION);
+			pci_dev_put(dev);
 			dev = pci_get_domain_bus_and_slot(pci_domain_nr(ubox->bus),
 							  ubox->bus->number,
 							  devfn);
-- 
2.39.5 (Apple Git-154)


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] x86/events/intel/uncore: fix PCI refcount leak in discover_upi_topology
  2026-06-28 11:17 [PATCH v2] x86/events/intel/uncore: fix PCI refcount leak in discover_upi_topology WenTao Liang
@ 2026-06-29  2:32 ` Mi, Dapeng
  0 siblings, 0 replies; 2+ messages in thread
From: Mi, Dapeng @ 2026-06-29  2:32 UTC (permalink / raw)
  To: WenTao Liang, linux-perf-users
  Cc: peterz, mingo, acme, namhyung, mark.rutland, alexander.shishkin,
	jolsa, irogers, adrian.hunter, james.clark, tglx, bp, dave.hansen,
	x86, hpa, linux-kernel, stable, Greg KH


On 6/28/2026 7:17 PM, WenTao Liang wrote:
> In the inner for loop, dev is repeatedly overwritten by
> pci_get_domain_bus_and_slot() without first releasing the previous dev
> via pci_dev_put(). The err label only releases the last ubox and dev
> references, while the references from earlier loop iterations are
> permanently leaked. Fix by adding pci_dev_put(dev) before the overwriting
> assignment.
>
> Suggested-by: Greg KH <gregkh@linuxfoundation.org>
> Fixes: fdd041028f22 ("perf/x86/intel/uncore: Factor out topology_gidnid_map()")
> Cc: stable@vger.kernel.org
> Signed-off-by: WenTao Liang <vulab@iscas.ac.cn>
> ---
> Changes in v2:
> - Fix patch format based on reviewer feedback
> ---
> ---
>  arch/x86/events/intel/uncore_snbep.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c
> index 215d33e260ed..cecc1ce0a248 100644
> --- a/arch/x86/events/intel/uncore_snbep.c
> +++ b/arch/x86/events/intel/uncore_snbep.c
> @@ -5494,6 +5494,7 @@ static int discover_upi_topology(struct intel_uncore_type *type, int ubox_did, i
>  		for (idx = 0; idx < type->num_boxes; idx++) {
>  			upi = &type->topology[lgc_pkg][idx];
>  			devfn = PCI_DEVFN(dev_link0 + idx, ICX_UPI_REGS_ADDR_FUNCTION);
> +			pci_dev_put(dev);
>  			dev = pci_get_domain_bus_and_slot(pci_domain_nr(ubox->bus),
>  							  ubox->bus->number,
>  							  devfn);

I have replied previous patch, I suppose this issue has been fixed by this
patch
https://lore.kernel.org/all/20260602144908.263680-4-zide.chen@intel.com/,
isn't it? Thanks.



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-06-29  2:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-28 11:17 [PATCH v2] x86/events/intel/uncore: fix PCI refcount leak in discover_upi_topology WenTao Liang
2026-06-29  2:32 ` Mi, Dapeng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox