Re: [PATCH v2] x86/events/intel/uncore: fix PCI refcount leak in discover_upi_topology

From: Mi, Dapeng

Date: Sun Jun 28 2026 - 22:35:50 EST



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@xxxxxxxxxxxxxxxxxxx>
> Fixes: fdd041028f22 ("perf/x86/intel/uncore: Factor out topology_gidnid_map()")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: WenTao Liang <vulab@xxxxxxxxxxx>
> ---
> 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@xxxxxxxxx/,
isn't it? Thanks.