104-of-Add-check-to-of_scan_flat_dt-before-accessing-ini.patch 981 B

123456789101112131415161718192021222324252627282930
  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. An empty __dtb_start to __dtb_end section might result in initial_boot_params
  6. being null for arch/mips/ralink. This showed that the boot process hangs
  7. indefinitely in of_scan_flat_dt().
  8. Signed-off-by: Tobias Wolf <dev-NTEO@vplace.de>
  9. ---
  10. --- a/drivers/of/fdt.c
  11. +++ b/drivers/of/fdt.c
  12. @@ -632,9 +632,12 @@ int __init of_scan_flat_dt(int (*it)(uns
  13. const char *pathp;
  14. int offset, rc = 0, depth = -1;
  15. - for (offset = fdt_next_node(blob, -1, &depth);
  16. - offset >= 0 && depth >= 0 && !rc;
  17. - offset = fdt_next_node(blob, offset, &depth)) {
  18. + if (!blob)
  19. + return 0;
  20. +
  21. + for (offset = fdt_next_node(blob, -1, &depth);
  22. + offset >= 0 && depth >= 0 && !rc;
  23. + offset = fdt_next_node(blob, offset, &depth)) {
  24. pathp = fdt_get_name(blob, offset, NULL);
  25. if (*pathp == '/')