diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2018-01-17 14:19:13 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2018-01-17 14:21:08 +0100 |
commit | 11bc2f40415299028576fb88da1caa8f1561ebe5 (patch) | |
tree | 343a63f0e6eb5e2bcf94496fe31eabd4e8af7c2f | |
parent | db02aac6be9267ccc1a93ffec6c1f49352cf719a (diff) | |
download | barebox-11bc2f40415299028576fb88da1caa8f1561ebe5.tar.gz barebox-11bc2f40415299028576fb88da1caa8f1561ebe5.tar.xz |
FIT: Fix error path
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>
-rw-r--r-- | common/image-fit.c | 8 |
1 files 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); |