Skip to contentSkip to conversation

pasemi: fix PCI device reference leaks in pas_setup_mce_regs

PATCH In review Miaoqian Lin 4 participants 5 messages Sep 2, 2025

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

PATCH 1/1 pasemi: fix PCI device reference leaks in pas_setup_mce_regs

Fix reference leaks where PCI device references obtained via pci_get_device() were not being released:

1. The while loop that iterates through 0xa00a devices was not releasing the final device reference when the loop terminates.

2. Single device lookups for 0xa001 and 0xa009 devices were not releasing their references after use.

Add missing pci_dev_put() calls to ensure all device references are properly released.

Fixes cd7834167ffb ("[POWERPC] pasemi: Print more information at machine check")
---
 arch/powerpc/platforms/pasemi/setup.c | 4 ++++
 1 file changed, 4 insertions(+)
arch/powerpc/platforms/pasemi/setup.c +4 -0
index d03b41336901..dafbee3afd86 100644
@@ -169,6 +169,8 @@ static int __init pas_setup_mce_regs(void)
 		dev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa00a, dev);
 		reg++;
 	}
+	/* Release the last device reference from the while loop */
+	pci_dev_put(dev);
 
 	dev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa001, NULL);
 	if (dev && reg+4 < MAX_MCE_REGS) {
@@ -185,6 +187,7 @@ static int __init pas_setup_mce_regs(void)
 		mce_regs[reg].addr = pasemi_pci_getcfgaddr(dev, 0xc1c);
 		reg++;
 	}
+	pci_dev_put(dev);
 
 	dev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa009, NULL);
 	if (dev && reg+2 < MAX_MCE_REGS) {
@@ -195,6 +198,7 @@ static int __init pas_setup_mce_regs(void)
 		mce_regs[reg].addr = pasemi_pci_getcfgaddr(dev, 0x214);
 		reg++;
 	}
+	pci_dev_put(dev);
 
 	num_mce_regs = reg;
 
Signature · 1 line
2.35.1
#1 lore raw

…

Quoted 2 lines

Add missing pci_dev_put() calls to ensure all device references are properly released.

* See also:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17-rc4#n658

* Would you like to increase the application of scope-based resource management?
https://elixir.bootlin.com/linux/v6.17-rc4/source/include/linux/device.h#L1180

* How do you think about to append parentheses to the function name in the summary phrase?

Regards,
Markus

#2 lore raw
Quoted 6 lines · Markus Elfring

…

Quoted 2 lines

Add missing pci_dev_put() calls to ensure all device references are properly released.

* See also:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17-rc4#n658

?

Quoted 2 lines

* Would you like to increase the application of scope-based resource management?
https://elixir.bootlin.com/linux/v6.17-rc4/source/include/linux/device.h#L1180

That won't work here at all.

Signature · 2 lines
js
suse labs
#4 lore raw
In reply to Markus Elfring
Quoted 4 lines · Markus Elfring

…

Quoted 2 lines

Add missing pci_dev_put() calls to ensure all device references are properly released.

Quoted 8 lines

* See also:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17-rc4#n658

* Would you like to increase the application of scope-based resource management?
https://elixir.bootlin.com/linux/v6.17-rc4/source/include/linux/device.h#L1180

* How do you think about to append parentheses to the function name in the summary phrase?

Hi,

This is the semi-friendly patch-bot of Greg Kroah-Hartman.

Markus, you seem to have sent a nonsensical or otherwise pointless review comment to a patch submission on a Linux kernel developer mailing list. I strongly suggest that you not do this anymore. Please do not bother developers who are actively working to produce patches and features with comments that, in the end, are a waste of time.

Patch submitter, please ignore Markus's suggestion; you do not need to follow it at all. The person/bot/AI that sent it is being ignored by almost all Linux kernel maintainers for having a persistent pattern of behavior of producing distracting and pointless commentary, and inability to adapt to feedback. Please feel free to also ignore emails from them.

thanks,

greg k-h's patch email bot