Skip to content

Commit 7dfea16

Browse files
Tobias Wolfgregkh
authored andcommitted
of: Add check to of_scan_flat_dt() before accessing initial_boot_params
commit 3ec754410cb3e931a6c4920b1a150f21a94a2bf4 upstream. An empty __dtb_start to __dtb_end section might result in initial_boot_params being null for arch/mips/ralink. This showed that the boot process hangs indefinitely in of_scan_flat_dt(). Signed-off-by: Tobias Wolf <dev-NTEO@vplace.de> Cc: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/14605/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org> Signed-off-by: Amit Pundir <amit.pundir@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent eab38df commit 7dfea16

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

drivers/of/fdt.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -632,9 +632,12 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node,
632632
const char *pathp;
633633
int offset, rc = 0, depth = -1;
634634

635-
for (offset = fdt_next_node(blob, -1, &depth);
636-
offset >= 0 && depth >= 0 && !rc;
637-
offset = fdt_next_node(blob, offset, &depth)) {
635+
if (!blob)
636+
return 0;
637+
638+
for (offset = fdt_next_node(blob, -1, &depth);
639+
offset >= 0 && depth >= 0 && !rc;
640+
offset = fdt_next_node(blob, offset, &depth)) {
638641

639642
pathp = fdt_get_name(blob, offset, NULL);
640643
if (*pathp == '/')

0 commit comments

Comments
 (0)