[PATCH 22/32] of: fdt: gracefully handle out-of-place properties
Ahmad Fatoum
a.fatoum at pengutronix.de
Mon Sep 5 02:55:47 PDT 2022
node is initialized by FDT_BEGIN_NODE. In case where a FDT_PROP is
encountered before the first FDT_BEGIN_NODE, we would end up
dereferencing a NULL pointer. Handle such malformed device trees
gracefully by returning with an -ESPIPE error instead.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
drivers/of/fdt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 42f45bbd4fb5..01d7dc37439f 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -212,7 +212,7 @@ static struct device_node *__of_unflatten_dtb(const void *infdt, int size,
nodep = fdt_prop->data;
name = dt_string(&f, dt_strings, fdt32_to_cpu(fdt_prop->nameoff));
- if (!name) {
+ if (!name || !node) {
ret = -ESPIPE;
goto err;
}
--
2.30.2
More information about the barebox
mailing list