mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] eisa/pci_eisa: Fix PCI device refcount leak on early init error
@ 2025-12-30  6:23 Kaushlendra Kumar
  0 siblings, 0 replies; only message in thread
From: Kaushlendra Kumar @ 2025-12-30  6:23 UTC (permalink / raw)
  To: bhelgaas, yinghai; +Cc: linux-kernel, Kaushlendra Kumar, stable

The for_each_pci_dev() loop takes a reference on each PCI device
during iteration. When returning early on pci_eisa_init() failure,
the reference on 'dev' is not released, causing a resource leak.

Add pci_dev_put(dev) before the error return to properly balance
the reference count taken by for_each_pci_dev().

Fixes: c5fb301ae83b ("EISA/PCI: Init EISA early, before PNP")
Cc: stable@vger.kernel.org
Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
---
 drivers/eisa/pci_eisa.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/eisa/pci_eisa.c b/drivers/eisa/pci_eisa.c
index 8173e60bb808..8242e9e16ce2 100644
--- a/drivers/eisa/pci_eisa.c
+++ b/drivers/eisa/pci_eisa.c
@@ -80,8 +80,10 @@ static int __init pci_eisa_init_early(void)
 	for_each_pci_dev(dev)
 		if ((dev->class >> 8) == PCI_CLASS_BRIDGE_EISA) {
 			ret = pci_eisa_init(dev);
-			if (ret)
+			if (ret) {
+				pci_dev_put(dev);
 				return ret;
+			}
 		}
 
 	return 0;
-- 
2.34.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-12-30  6:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-30  6:23 [PATCH] eisa/pci_eisa: Fix PCI device refcount leak on early init error Kaushlendra Kumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®