kernel: update kernel 4.9 to 4.9.30
[openwrt/staging/chunkeey.git] / target / linux / generic / patches-4.9 / 121-of-Add-check-to-of_scan_flat_dt-before-accessing-ini.patch
1 From: Tobias Wolf <dev-NTEO@vplace.de>
2 Date: Wed, 23 Nov 2016 10:40:07 +0100
3 Subject: [PATCH] of: Add check to of_scan_flat_dt() before accessing
4 initial_boot_params
5
6 An empty __dtb_start to __dtb_end section might result in initial_boot_params
7 being null for arch/mips/ralink. This showed that the boot process hangs
8 indefinitely in of_scan_flat_dt().
9
10 Signed-off-by: Tobias Wolf <dev-NTEO@vplace.de>
11 ---
12
13 --- a/drivers/of/fdt.c
14 +++ b/drivers/of/fdt.c
15 @@ -741,9 +741,12 @@ int __init of_scan_flat_dt(int (*it)(uns
16 const char *pathp;
17 int offset, rc = 0, depth = -1;
18
19 - for (offset = fdt_next_node(blob, -1, &depth);
20 - offset >= 0 && depth >= 0 && !rc;
21 - offset = fdt_next_node(blob, offset, &depth)) {
22 + if (!blob)
23 + return 0;
24 +
25 + for (offset = fdt_next_node(blob, -1, &depth);
26 + offset >= 0 && depth >= 0 && !rc;
27 + offset = fdt_next_node(blob, offset, &depth)) {
28
29 pathp = fdt_get_name(blob, offset, NULL);
30 if (*pathp == '/')