]> git.ipfire.org Git - thirdparty/linux.git/commit
perf/x86/intel/uncore: Fix PCI device refcount leak in UPI discovery
authorZide Chen <zide.chen@intel.com>
Tue, 2 Jun 2026 14:49:04 +0000 (07:49 -0700)
committerPeter Zijlstra <peterz@infradead.org>
Thu, 4 Jun 2026 09:38:37 +0000 (11:38 +0200)
commit81ec618f59415bdcf3e8989e2691c1f240be27fb
tree72ad695d6470cffc8f07f1ad3b42e3ba164b7e39
parent3c19ea24f02658c4b8ad364458fae4d77fdb3fae
perf/x86/intel/uncore: Fix PCI device refcount leak in UPI discovery

pci_get_domain_bus_and_slot() increments the reference count of the
returned PCI device and therefore requires a matching pci_dev_put().

In skx_upi_topology_cb() and discover_upi_topology(), the lookup is
performed inside a loop, but pci_dev_put() is only called once after
the loop. As a result, references from all previous iterations are
leaked.

Move pci_dev_put(dev) into the if (dev) block immediately after
upi_fill_topology() returns.

Opportunistically, fix uninitialized variable in skx_upi_topology_cb().

Fixes: 4cfce57fa42d ("perf/x86/intel/uncore: Enable UPI topology discovery for Skylake Server")
Fixes: f680b6e6062e ("perf/x86/intel/uncore: Enable UPI topology discovery for Icelake Server")
Signed-off-by: Zide Chen <zide.chen@intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
Link: https://patch.msgid.link/20260602144908.263680-4-zide.chen@intel.com
arch/x86/events/intel/uncore_snbep.c