From: Changbin Du <changbin.du@gmail.com>
To: Rob Herring <robh+dt@kernel.org>, Frank Rowand <frowand.list@gmail.com>
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
Changbin Du <changbin.du@gmail.com>
Subject: [PATCH] of/fdt: Check dtb pointer first in unflatten_device_tree
Date: Wed, 24 Mar 2021 23:04:25 +0800 [thread overview]
Message-ID: <20210324150425.20688-1-changbin.du@gmail.com> (raw)
The setup_arch() would invoke unflatten_device_tree() even no
valid fdt found. So we'd better check it first and return early.
Signed-off-by: Changbin Du <changbin.du@gmail.com>
---
drivers/of/fdt.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index dcc1dd96911a..05d439d63bc5 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -1225,6 +1225,11 @@ bool __init early_init_dt_scan(void *params)
*/
void __init unflatten_device_tree(void)
{
+ if (!initial_boot_params) {
+ pr_warn("No valid device tree found, continuing without\n");
+ return;
+ }
+
__unflatten_device_tree(initial_boot_params, NULL, &of_root,
early_init_dt_alloc_memory_arch, false);
--
2.30.2
next reply other threads:[~2021-03-24 15:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-24 15:04 Changbin Du [this message]
2021-03-24 16:52 ` [PATCH] of/fdt: Check dtb pointer first in unflatten_device_tree Rob Herring
2021-03-25 16:00 ` Changbin Du
2021-03-25 16:28 ` Rob Herring
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=20210324150425.20688-1-changbin.du@gmail.com \
--to=changbin.du@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=frowand.list@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=robh+dt@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).