COOLING4d

[PATCH] PCI: rpaphp: report first slot registration error

From: Adriano Cordova <hidden>
Date: 2026-09-10 12:13:45
Also in: linux-pci, lkml
Subsystem: ibm power pci hotplug driver for rpa-compliant ppc64 platform, linux for powerpc (32-bit and 64-bit), pci subsystem, the rest · Maintainers: Tyrel Datwyler, Madhavan Srinivasan, Bjorn Helgaas, Linus Torvalds

rpaphp_drc_add_slot() overwrites retval on every loop iteration, so a
failure to register a slot is lost if a later slot registers
successfully and the function returns success.

Track the first error and return it, while still attempting to register
the remaining slots.

Signed-off-by: Adriano Cordova <redacted>
---
 drivers/pci/hotplug/rpaphp_core.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c
index 2316de0fd198..af7241d526cf 100644
--- a/drivers/pci/hotplug/rpaphp_core.c
+++ b/drivers/pci/hotplug/rpaphp_core.c
@@ -376,6 +376,7 @@ static int rpaphp_drc_add_slot(struct device_node *dn)
 {
 	struct slot *slot;
 	int retval = 0;
+	int first_error = 0;
 	int i;
 	const __be32 *indexes, *names, *types, *power_domains;
 	char *name, *type;
@@ -407,16 +408,18 @@ static int rpaphp_drc_add_slot(struct device_node *dn)
 		if (!retval)
 			retval = rpaphp_register_slot(slot);
 
-		if (retval)
+		if (retval) {
+			if (!first_error)
+				first_error = retval;
 			dealloc_slot_struct(slot);
+		}
 
 		name += strlen(name) + 1;
 		type += strlen(type) + 1;
 	}
-	dbg("%s - Exit: rc[%d]\n", __func__, retval);
+	dbg("%s - Exit: rc[%d]\n", __func__, first_error);
 
-	/* XXX FIXME: reports a failure only if last entry in loop failed */
-	return retval;
+	return first_error;
 }
 
 /**
-- 
2.51.0

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help