[PATCH 2/2 v3] of: Add check to of_scan_flat_dt() before accessing initial_boot_params

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -738,9 +738,12 @@
 	const char *pathp;
 	int offset, rc = 0, depth = -1;
 
-        for (offset = fdt_next_node(blob, -1, &depth);
-             offset >= 0 && depth >= 0 && !rc;
-             offset = fdt_next_node(blob, offset, &depth)) {
+	if (!blob)
+		return 0;
+
+	for (offset = fdt_next_node(blob, -1, &depth);
+	     offset >= 0 && depth >= 0 && !rc;
+	     offset = fdt_next_node(blob, offset, &depth)) {
 
 		pathp = fdt_get_name(blob, offset, NULL);
 		if (*pathp == '/')

Dear Sergei,

Missed that warning completely during compilation of a testable image for my 
device. I regenerated the patch based on your input (for 4.9-rc6 this time) 
and based the check on the local blob variable this time.

Haven't seen any warnings this time.

Hope it's correct that I reference the new patch version each time in the 
subject line.

Best regards
Tobias

Btw.: Last e-mail I wanted to list occurrences EINVAL would break existing 
code. One is kernel/prom.c in arch/microblaze.




[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux