mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH] FIT: Fix error path
Date: Wed, 17 Jan 2018 14:22:33 +0100	[thread overview]
Message-ID: <20180117132233.19806-1-s.hauer@pengutronix.de> (raw)

In case of error of_unflatten_dtb() returns an ERR_PTR. Make sure
that handle->root contains NULL in this case so that we do not call
of_delete_node on the error pointer in the exit path.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/image-fit.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/common/image-fit.c b/common/image-fit.c
index 81433e6ecf..db5d142147 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -584,6 +584,7 @@ struct fit_handle *fit_open(const char *filename, const char *config, bool verbo
 {
 	struct fit_handle *handle = NULL;
 	const char *desc = "(no description)";
+	struct device_node *root;
 	int ret;
 
 	handle = xzalloc(sizeof(struct fit_handle));
@@ -596,12 +597,13 @@ struct fit_handle *fit_open(const char *filename, const char *config, bool verbo
 		goto err;
 	}
 
-	handle->root = of_unflatten_dtb(handle->fit);
-	if (IS_ERR(handle->root)) {
-		ret = PTR_ERR(handle->root);
+	root = of_unflatten_dtb(handle->fit);
+	if (IS_ERR(root)) {
+		ret = PTR_ERR(root);
 		goto err;
 	}
 
+	handle->root = root;
 	handle->verify = verify;
 
 	of_property_read_string(handle->root, "description", &desc);
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

                 reply	other threads:[~2018-01-17 13:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20180117132233.19806-1-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --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