platform/x86: intel_telemetry: Fix PCI device ref leak
Subsystems (2)
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().
--- drivers/platform/x86/intel/telemetry/debugfs.c | 1 + 1 file changed, 1 insertion(+)
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); }seq_puts (s,"\n--------------------------------------\n" );
Signature · 1 line
2.34.1
Ilpo Järvinen
maintainerQuoted 18 lines · Kaushlendra Kumar
The
for_each_pci_dev()macro increments the reference count for each PCI device. Without callingpci_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 byfor_each_pci_dev().Fixes 87bee290998d ("platform:x86: Add Intel Telemetry Debugfs interfaces")Signed-off-by Kaushlendra Kumar <[email protected]>--- drivers/platform/x86/intel/telemetry/debugfs.c | 1 + 1 file changed, 1 insertion(+)drivers/platform/x86/intel/telemetry/debugfs.c +0
-0
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.
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