From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: barebox@lists.infradead.org
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>
Subject: [PATCH] of_unflatten_dtb(): Check return value with IS_ERR
Date: Thu, 1 Sep 2016 13:39:58 -0700 [thread overview]
Message-ID: <1472762398-16172-1-git-send-email-andrew.smirnov@gmail.com> (raw)
Of_unflatten_dtb returns a ERR_PTR value so checking it against NULL is
incorrect. Fix it in all of the places where this was happening.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
arch/arm/boards/highbank/init.c | 2 +-
arch/arm/cpu/dtb.c | 2 +-
arch/arm/lib/bootm.c | 2 +-
arch/mips/boot/dtb.c | 2 +-
arch/openrisc/lib/dtb.c | 2 +-
common/bootm.c | 6 +++++-
6 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/arch/arm/boards/highbank/init.c b/arch/arm/boards/highbank/init.c
index 1cb02e6..295d475 100644
--- a/arch/arm/boards/highbank/init.c
+++ b/arch/arm/boards/highbank/init.c
@@ -77,7 +77,7 @@ static int highbank_mem_init(void)
fdt = IOMEM(FIRMWARE_DTB_BASE);
root = of_unflatten_dtb(fdt);
- if (!root) {
+ if (IS_ERR(root)) {
pr_warn("no dtb found at 0x1000 use default configuration\n");
fdt = NULL;
goto not_found;
diff --git a/arch/arm/cpu/dtb.c b/arch/arm/cpu/dtb.c
index ae4ff2a..b9390b4 100644
--- a/arch/arm/cpu/dtb.c
+++ b/arch/arm/cpu/dtb.c
@@ -48,7 +48,7 @@ static int of_arm_init(void)
}
root = of_unflatten_dtb(fdt);
- if (root) {
+ if (!IS_ERR(root)) {
of_set_root_node(root);
of_fix_tree(root);
if (IS_ENABLED(CONFIG_OFDEVICE))
diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
index 0e81a66..7bddacd 100644
--- a/arch/arm/lib/bootm.c
+++ b/arch/arm/lib/bootm.c
@@ -225,7 +225,7 @@ static int do_bootz_linux_fdt(int fd, struct image_data *data)
if (IS_BUILTIN(CONFIG_OFTREE)) {
data->of_root_node = of_unflatten_dtb(oftree);
- if (!data->of_root_node) {
+ if (IS_ERR(data->of_root_node)) {
pr_err("unable to unflatten devicetree\n");
ret = -EINVAL;
goto err_free;
diff --git a/arch/mips/boot/dtb.c b/arch/mips/boot/dtb.c
index 977c837..e7633a5 100644
--- a/arch/mips/boot/dtb.c
+++ b/arch/mips/boot/dtb.c
@@ -51,7 +51,7 @@ static int of_mips_init(void)
return 0;
root = of_unflatten_dtb(__dtb_start);
- if (root) {
+ if (!IS_ERR(root)) {
pr_debug("using internal DTB\n");
of_set_root_node(root);
if (IS_ENABLED(CONFIG_OFDEVICE))
diff --git a/arch/openrisc/lib/dtb.c b/arch/openrisc/lib/dtb.c
index 4f63a77..04bb6d2 100644
--- a/arch/openrisc/lib/dtb.c
+++ b/arch/openrisc/lib/dtb.c
@@ -32,7 +32,7 @@ static int of_openrisc_init(void)
return 0;
root = of_unflatten_dtb(__dtb_start);
- if (root) {
+ if (!IS_ERR(root)) {
pr_debug("using internal DTB\n");
of_set_root_node(root);
if (IS_ENABLED(CONFIG_OFDEVICE))
diff --git a/common/bootm.c b/common/bootm.c
index 78d04d5..5984319 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -336,6 +336,9 @@ int bootm_load_devicetree(struct image_data *data, unsigned long load_address)
if (data->os_fit && data->os_fit->oftree) {
data->of_root_node = of_unflatten_dtb(data->os_fit->oftree);
+
+ if (IS_ERR(data->of_root_node))
+ data->of_root_node = NULL;
} else if (data->oftree_file) {
size_t size;
@@ -367,7 +370,8 @@ int bootm_load_devicetree(struct image_data *data, unsigned long load_address)
free(oftree);
- if (!data->of_root_node) {
+ if (IS_ERR(data->of_root_node)) {
+ data->of_root_node = NULL;
pr_err("unable to unflatten devicetree\n");
return -EINVAL;
}
--
2.5.5
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next reply other threads:[~2016-09-01 20:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-01 20:39 Andrey Smirnov [this message]
2016-09-05 6:29 ` Sascha Hauer
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=1472762398-16172-1-git-send-email-andrew.smirnov@gmail.com \
--to=andrew.smirnov@gmail.com \
--cc=barebox@lists.infradead.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