[PATCH v2] of: Put coreboot node after compatibility check

From: Yuho Choi

Date: Wed Sep 23 2026 - 21:14:28 EST


of_find_compatible_node() returns a referenced device node, but
EXCLUDED_DEFAULT_CELLS_PLATFORMS used the result only as a boolean and
discarded the reference. This leaked a reference each time the
address-cells or size-cells warning condition was evaluated on a
coreboot system.

Use a helper that checks for the coreboot node with a scoped reference,
so the reference is dropped once the check is done.

Fixes: 8600058ba28a7 ("of: Add coreboot firmware to excluded default cells list")
Signed-off-by: Yuho Choi <oss.patchbox@xxxxxxxxx>
---
Changes in v2:
- Use __free(device_node) in of_coreboot_present() (Krzysztof Kozlowski)
- Switch to my oss.patchbox address

v1: https://lore.kernel.org/all/20260802023821.494178-1-dbgh9129@xxxxxxxxx/

drivers/of/base.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index d71ae0449360..f63a9486b130 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -96,9 +96,17 @@ static bool __of_node_is_type(const struct device_node *np, const char *type)
return !strcmp(match, type);
}

+static bool of_coreboot_present(void)
+{
+ struct device_node *np __free(device_node) =
+ of_find_compatible_node(NULL, NULL, "coreboot");
+
+ return np;
+}
+
#define EXCLUDED_DEFAULT_CELLS_PLATFORMS ( \
IS_ENABLED(CONFIG_SPARC) || \
- of_find_compatible_node(NULL, NULL, "coreboot") \
+ of_coreboot_present() \
)

int of_bus_n_addr_cells(struct device_node *np)

base-commit: f0100363d8c374bd8e9ea7c9ba02744f0b802ca4
--
2.43.0