Skip to content

Commit 17b8d84

Browse files
fenghusthuPeter Zijlstra
authored andcommitted
perf/x86/intel/uncore: Fix reference count leak in __uncore_imc_init_box()
pci_get_device() will increase the reference count for the returned pci_dev, so tgl_uncore_get_mc_dev() will return a pci_dev with its reference count increased. We need to call pci_dev_put() to decrease the reference count before exiting from __uncore_imc_init_box(). Add pci_dev_put() for both normal and error path. Fixes: fdb6482 ("perf/x86: Add Intel Tiger Lake uncore support") Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Kan Liang <kan.liang@linux.intel.com> Link: https://lore.kernel.org/r/20221118063137.121512-5-wangxiongfeng2@huawei.com
1 parent 8ebd16c commit 17b8d84

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

arch/x86/events/intel/uncore_snb.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,6 +1338,7 @@ static void __uncore_imc_init_box(struct intel_uncore_box *box,
13381338
/* MCHBAR is disabled */
13391339
if (!(mch_bar & BIT(0))) {
13401340
pr_warn("perf uncore: MCHBAR is disabled. Failed to map IMC free-running counters.\n");
1341+
pci_dev_put(pdev);
13411342
return;
13421343
}
13431344
mch_bar &= ~BIT(0);
@@ -1352,6 +1353,8 @@ static void __uncore_imc_init_box(struct intel_uncore_box *box,
13521353
box->io_addr = ioremap(addr, type->mmio_map_size);
13531354
if (!box->io_addr)
13541355
pr_warn("perf uncore: Failed to ioremap for %s.\n", type->name);
1356+
1357+
pci_dev_put(pdev);
13551358
}
13561359

13571360
static void tgl_uncore_imc_freerunning_init_box(struct intel_uncore_box *box)

0 commit comments

Comments
 (0)