[PATCH] pasemi: fix PCI device reference leaks in pas_setup_mce_regs

Miaoqian Lin posted 1 patch 1 month ago
arch/powerpc/platforms/pasemi/setup.c | 4 ++++
1 file changed, 4 insertions(+)
[PATCH] pasemi: fix PCI device reference leaks in pas_setup_mce_regs
Posted by Miaoqian Lin 1 month ago
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")
Cc: stable@vger.kernel.org
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 arch/powerpc/platforms/pasemi/setup.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/powerpc/platforms/pasemi/setup.c b/arch/powerpc/platforms/pasemi/setup.c
index d03b41336901..dafbee3afd86 100644
--- a/arch/powerpc/platforms/pasemi/setup.c
+++ b/arch/powerpc/platforms/pasemi/setup.c
@@ -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;
 
-- 
2.35.1
Re: [PATCH] pasemi: fix PCI device reference leaks in pas_setup_mce_regs
Posted by Markus Elfring 1 month ago
…
> 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
Re: [PATCH] pasemi: fix PCI device reference leaks in pas_setup_mce_regs
Posted by Greg KH 1 month ago
On Tue, Sep 02, 2025 at 12:24:11PM +0200, Markus Elfring wrote:
> …
> > 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?


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
Re: [PATCH] pasemi: fix PCI device reference leaks in pas_setup_mce_regs
Posted by Jiri Slaby 1 month ago
On 02. 09. 25, 12:24, Markus Elfring wrote:
> …
>> 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

That won't work here at all.

-- 
js
suse labs
Re: pasemi: fix PCI device reference leaks in pas_setup_mce_regs
Posted by Markus Elfring 1 month ago
>> * 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.

Why do you think in this direction here?

Regards,
Markus