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@xxxxxxxxxxxxxx> --- 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