Skip to contentSkip to conversation

platform/x86: intel_telemetry: Fix PCI device ref leak

PATCH In review Kaushlendra Kumar 2 participants 3 messages Dec 24, 2025 – Dec 30, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/x86: intel_telemetry: Fix PCI device ref leak

The for_each_pci_dev() macro increments the reference count for each PCI device. Without calling pci_dev_put() to release these references, the code leaks device references.

Add pci_dev_put() at the end of each iteration to properly release the reference taken by for_each_pci_dev().

Fixes 87bee290998d ("platform:x86: Add Intel Telemetry Debugfs interfaces")
---
 drivers/platform/x86/intel/telemetry/debugfs.c | 1 +
 1 file changed, 1 insertion(+)
drivers/platform/x86/intel/telemetry/debugfs.c +1 -0
index 189c61ff7ff0..8fdc9965ff27 100644
@@ -589,6 +589,7 @@ static int telem_soc_states_show(struct seq_file *s, void *unused)
 			   dev->vendor, dev->device, dev_name(&dev->dev),
 			   dev_driver_string(&dev->dev));
 		seq_printf(s, " d3:%x\n", d3_state);
+		pci_dev_put(dev);
 	}
 
 	seq_puts(s, "\n--------------------------------------\n");
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 18 lines · Kaushlendra Kumar

The for_each_pci_dev() macro increments the reference count for each PCI device. Without calling pci_dev_put() to release these references, the code leaks device references.

Add pci_dev_put() at the end of each iteration to properly release the reference taken by for_each_pci_dev().

Fixes 87bee290998d ("platform:x86: Add Intel Telemetry Debugfs interfaces")
---
 drivers/platform/x86/intel/telemetry/debugfs.c | 1 +
 1 file changed, 1 insertion(+)
drivers/platform/x86/intel/telemetry/debugfs.c +0 -0
index 189c61ff7ff0..8fdc9965ff27 100644

drivers/platform/x86/intel/telemetry/debugfs.c static int telem_soc_states_show(struct seq_file *s, void *unused) · line 593

Quoted 5 lines
drivers/platform/x86/intel/telemetry/debugfs.c +1 -0
@@ -589,6 +589,7 @@ static int telem_soc_states_show(struct seq_file *s, void *unused)
 			   dev->vendor, dev->device, dev_name(&dev->dev),
 			   dev_driver_string(&dev->dev));
 		seq_printf(s, " d3:%x\n", d3_state);
+		pci_dev_put(dev);
 	}

Hi,

This looks incorrect as the loop keeps iterating forward so it will decrement the reference count for dev.

Signature · 1 line
 i.
#2 lore raw
Quoted 4 lines · Ilpo Järvinen

Hi,

This looks incorrect as the loop keeps iterating forward so it will decrement the reference count for dev.

Hi Ilpo,

You're right, I apologize for the confusion.
.
I'll drop this patch.

Thanks for catching this.

Kaushlendra