Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: Tobias Wolf <dev-NTEO@vplace.de>
To: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Cc: linux-mips@linux-mips.org
Subject: [PATCH 2/2 v3] of: Add check to of_scan_flat_dt() before accessing initial_boot_params
Date: Wed, 23 Nov 2016 10:40:07 +0100	[thread overview]
Message-ID: <14509742.WUbz5chXyR@loki> (raw)
In-Reply-To: <d6072e00-1ca4-d461-e15d-3b7b92a7b998@cogentembedded.com>

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>
---
--- 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.

  reply	other threads:[~2016-11-23  9:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <3700342.djbc9u0nWG@loki>
2016-11-21 16:22 ` [PATCH 1/2] ralink: Introduce fw_passed_dtb to arch/mips/ralink Tobias Wolf
     [not found] ` <2966402.rBqcQZDeOh@loki>
2016-11-21 16:23   ` [PATCH 2/2] of: Add check to of_scan_flat_dt() before accessing initial_boot_params Tobias Wolf
2016-11-21 17:21     ` Sergei Shtylyov
2016-11-21 17:35       ` Tobias Wolf
2016-11-23  6:11       ` [PATCH 2/2 v2] " Tobias Wolf
2016-11-23  8:47         ` Sergei Shtylyov
2016-11-23  9:40           ` Tobias Wolf [this message]
2016-12-13 10:46 ` [PATCH 1/2 v2] ralink: Introduce fw_passed_dtb to arch/mips/ralink Tobias Wolf
2016-12-13 22:40   ` John Crispin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=14509742.WUbz5chXyR@loki \
    --to=dev-nteo@vplace.de \
    --cc=linux-mips@linux-mips.org \
    --cc=sergei.shtylyov@cogentembedded.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox