[PATCH v3] coreboot_table: skip failing entries instead of aborting populate

Titouan Ameline de Cadeville posted 1 patch 1 month, 1 week ago
drivers/firmware/google/coreboot_table.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
[PATCH v3] coreboot_table: skip failing entries instead of aborting populate
Posted by Titouan Ameline de Cadeville 1 month, 1 week ago
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.

Signed-off-by: Titouan Ameline de Cadeville <titouan.ameline@gmail.com>
---
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(-)

diff --git a/drivers/firmware/google/coreboot_table.c b/drivers/firmware/google/coreboot_table.c
index c769631ea15d..a797ed1db161 100644
--- a/drivers/firmware/google/coreboot_table.c
+++ b/drivers/firmware/google/coreboot_table.c
@@ -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;
-- 
2.44.2
Re: [PATCH v3] coreboot_table: skip failing entries instead of aborting populate
Posted by Tzung-Bi Shih 1 month, 1 week ago
On Fri, May 01, 2026 at 11:43:22AM +0200, Titouan Ameline de Cadeville wrote:
> 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!
Re: [PATCH v3] coreboot_table: skip failing entries instead of aborting populate
Posted by Brian Norris 1 month, 1 week ago
On Fri, May 01, 2026 at 11:43:22AM +0200, Titouan Ameline de Cadeville wrote:
> 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.
> 
> Signed-off-by: Titouan Ameline de Cadeville <titouan.ameline@gmail.com>

Acked-by: Brian Norris <briannorris@chromium.org>