Skip to contentSkip to conversation

of: Put coreboot node after compatibility check

PATCH Applied Yuho Choi 2 participants 2 messages Sep 24 – Sep 30 Device tree

lore
Share & tools
lore

Yuho Choi

author
#0 lore raw

PATCH v2 1/1 of: Put coreboot node after compatibility check

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")

---
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/[email protected]/

 drivers/of/base.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/of/base.c +9 -1
index d71ae0449360..f63a9486b130 100644
@@ -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

Signature · 1 line
2.43.0
maintainer Applied
#1 lore raw
Quoted 16 lines · Yuho Choi

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")

---
Changes in v2:
- Use __free(device_node) in of_coreboot_present() (Krzysztof Kozlowski)
- Switch to my oss.patchbox address

Quoted 5 lines

v1: https://lore.kernel.org/all/[email protected]/

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

Applied, thanks!