summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2022-09-05 11:55:47 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2022-09-12 12:05:01 +0200
commit2b8bf0ce90ca6f78accc166605af7371161af4e6 (patch)
treecb2b3295b2aa04afc78c319e0b6ab10c2a531077 /drivers
parent117261aa15607682b2c4a2d692283eed80cea717 (diff)
downloadbarebox-2b8bf0ce90ca6f78accc166605af7371161af4e6.tar.gz
barebox-2b8bf0ce90ca6f78accc166605af7371161af4e6.tar.xz
of: fdt: gracefully handle out-of-place properties
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@pengutronix.de> Link: https://lore.barebox.org/20220905095557.596891-23-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/of/fdt.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 42f45bbd4f..01d7dc3743 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;
}