Skip to contentSkip to conversation

coreboot_table: skip failing entries instead of aborting populate

PATCH In review Titouan Ameline de Cadeville 3 participants 3 messages May 1 – May 3

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 coreboot_table: skip failing entries instead of aborting populate

coreboot_table_populate() registers devices one by one. If device_register() fails for one entry, the current code returns immediately, leaving previously registered devices orphaned on the coreboot bus with no cleanup path.

Since coreboot table entries are independent of each other, a failure on one entry should not prevent the others from being registered. This mirrors the strategy used by of_platform_populate(), which skips individual failures rather than aborting.

Move ptr_entry increment before device_register(), log a warning on failure, and continue the loop rather than aborting.

---
v3: move ptr_entry increment before device_register() to avoid
re-processing the same entry on failure (reported by Brian Norris)
v2: continue the loop on failure instead of unregistering all devices
(suggested by Julius Werner, with reference to of_platform_populate() from Brian Norris)

 drivers/firmware/google/coreboot_table.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/firmware/google/coreboot_table.c +3 -3
index c769631ea15d..a797ed1db161 100644
@@ -148,13 +148,13 @@ static int coreboot_table_populate(struct device *dev, void *ptr)
 			break;
 		}
 
+		ptr_entry += entry->size;
+
 		ret = device_register(&device->dev);
 		if (ret) {
+			dev_warn(dev, "failed to register coreboot device: %d\n", ret);
 			put_device(&device->dev);
-			return ret;
 		}
-
-		ptr_entry += entry->size;
 	}
 
 	return 0;
Signature · 1 line
2.44.2
Acked-by on v3 1/1
#1 lore raw
Quoted 10 lines · Titouan Ameline de Cadeville

coreboot_table_populate() registers devices one by one. If device_register() fails for one entry, the current code returns immediately, leaving previously registered devices orphaned on the coreboot bus with no cleanup path.

Since coreboot table entries are independent of each other, a failure on one entry should not prevent the others from being registered. This mirrors the strategy used by of_platform_populate(), which skips individual failures rather than aborting.

Quoted 4 lines

Move ptr_entry increment before device_register(), log a warning on failure, and continue the loop rather than aborting.

#2 lore raw
In reply to Titouan Ameline de Cadeville
Quoted 11 lines · Titouan Ameline de Cadeville

coreboot_table_populate() registers devices one by one. If device_register() fails for one entry, the current code returns immediately, leaving previously registered devices orphaned on the coreboot bus with no cleanup path.

Since coreboot table entries are independent of each other, a failure on one entry should not prevent the others from being registered. This mirrors the strategy used by of_platform_populate(), which skips individual failures rather than aborting.

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux.git for-firmware-next

[1/1] coreboot_table: skip failing entries instead of aborting populate

      commit: 86e3bbc716332600e9e087f8a4889f4d9714a99c

Thanks!