linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf/x86/intel/uncore: decrease reference count in error path
@ 2022-11-15 11:25 Xiongfeng Wang
  2022-11-15 14:03 ` Liang, Kan
  2022-11-15 16:25 ` Alexander Antonov
  0 siblings, 2 replies; 3+ messages in thread
From: Xiongfeng Wang @ 2022-11-15 11:25 UTC (permalink / raw)
  To: adrian.hunter, peterz, ak, kan.liang, alexander.shishkin,
	alexander.antonov, acme, jolsa
  Cc: linux-perf-users, yangyingliang, wangxiongfeng2

pci_get_device() will increase the reference count for the returned
pci_dev, and also decrease the reference count for the input parameter
*from* if it is not NULL.

If we break the loop in sad_cfg_iio_topology() with 'dev' not NULL. We
need to use pci_dev_put() to decrease the reference count. Let's add it.

Fixes: c1777be3646b ("perf/x86/intel/uncore: Enable I/O stacks to IIO PMON mapping on SNR")
Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>
---
 arch/x86/events/intel/uncore_snbep.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c
index ed869443efb2..83fe3d80c9a7 100644
--- a/arch/x86/events/intel/uncore_snbep.c
+++ b/arch/x86/events/intel/uncore_snbep.c
@@ -4469,6 +4469,7 @@ static int sad_cfg_iio_topology(struct intel_uncore_type *type, u8 *sad_pmon_map
 	while ((dev = pci_get_device(PCI_VENDOR_ID_INTEL, SNR_ICX_MESH2IIO_MMAP_DID, dev))) {
 		ret = pci_read_config_dword(dev, SNR_ICX_SAD_CONTROL_CFG, &sad_cfg);
 		if (ret) {
+			pci_dev_put(dev);
 			ret = pcibios_err_to_errno(ret);
 			break;
 		}
@@ -4476,6 +4477,7 @@ static int sad_cfg_iio_topology(struct intel_uncore_type *type, u8 *sad_pmon_map
 		die = uncore_pcibus_to_dieid(dev->bus);
 		stack_id = SAD_CONTROL_STACK_ID(sad_cfg);
 		if (die < 0 || stack_id >= type->num_boxes) {
+			pci_dev_put(dev);
 			ret = -EPERM;
 			break;
 		}
-- 
2.20.1


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

end of thread, other threads:[~2022-11-15 16:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-15 11:25 [PATCH] perf/x86/intel/uncore: decrease reference count in error path Xiongfeng Wang
2022-11-15 14:03 ` Liang, Kan
2022-11-15 16:25 ` Alexander Antonov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).