Re: [PATCH] fix: x86/events/intel/uncore: discover_upi_topology: inner loop leaks PCI device references from pci_get_domain_bus_and_slot
From: WenTao Liang
Date: Sat Jun 27 2026 - 23:52:47 EST
> 2026年6月26日 18:00,WenTao Liang <vulab@xxxxxxxxxxx> 写道:
>
> 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.
>
> Cc: stable@xxxxxxxxxxxxxxx
> Fixes: fdd041028f22 ("perf/x86/intel/uncore: Factor out topology_gidnid_map()")
> Signed-off-by: WenTao Liang <vulab@xxxxxxxxxxx>
> ---
> 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)
Please ignore this patch. I will resend a proper version after
learning the kernel submission process.
Apologies for the noise.
Best regards,
WenTao Liang