Linux PCI subsystem development
 help / color / mirror / Atom feed
* [PATCH] PCI: cpqhp: Release the device reference on config read failure
@ 2026-11-12  7:17 Zhu Jun
  2026-11-12  7:21 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Zhu Jun @ 2026-11-12  7:17 UTC (permalink / raw)
  To: bhelgaas; +Cc: linux-pci, linux-kernel, Zhu Jun

cpqhp_save_config() obtains a PCI device reference before saving its
configuration space. If a configuration read fails, the function
returns before reaching the matching pci_dev_put().

Drop the lookup reference on that error path as well as on success.

Fixes: 12a9da0fcb14 ("PCI Hotplug: cpqphp: don't use pci_find_slot()")
Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
---
 drivers/pci/hotplug/cpqphp_pci.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/hotplug/cpqphp_pci.c b/drivers/pci/hotplug/cpqphp_pci.c
index 81c58b1ec200..c24d311c8e44 100644
--- a/drivers/pci/hotplug/cpqphp_pci.c
+++ b/drivers/pci/hotplug/cpqphp_pci.c
@@ -409,8 +409,10 @@ int cpqhp_save_config(struct controller *ctrl, int busnumber, int is_hot_plug)
 
 			for (cloop = 0; cloop < 0x20; cloop++) {
 				rc = pci_bus_read_config_dword(ctrl->pci_bus, PCI_DEVFN(device, function), cloop << 2, (u32 *) &(new_slot->config_space[cloop]));
-				if (rc)
+				if (rc) {
+					pci_dev_put(new_slot->pci_dev);
 					return rc;
+				}
 			}
 
 			pci_dev_put(new_slot->pci_dev);
-- 
2.51.0




^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-12  7:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-12  7:17 [PATCH] PCI: cpqhp: Release the device reference on config read failure Zhu Jun
2026-11-12  7:21 ` sashiko-bot

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