summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2017-06-12 12:21:34 (GMT)
committerSimon Glass <sjg@chromium.org>2017-07-11 16:08:20 (GMT)
commitc1eb3d59662b27de6030413e819c2bc46c6156fe (patch)
treeb74de93df1afc5dc933d3365e0fd50894c4a76ba /lib
parent0be3a3b4732a0d66ff12b5e3abb1644fb884f13f (diff)
downloadu-boot-fsl-qoriq-c1eb3d59662b27de6030413e819c2bc46c6156fe.tar.xz
dm: Fix error handling when unflattening the DT
The error handling code does not current detect an error right away. Adjust it to return immediately. Signed-off-by: Simon Glass <sjg@chromium.org> Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com> Tested-on: Beaver, Jetson-TK1
Diffstat (limited to 'lib')
-rw-r--r--lib/of_live.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/of_live.c b/lib/of_live.c
index 51927f9..f351483 100644
--- a/lib/of_live.c
+++ b/lib/of_live.c
@@ -216,9 +216,12 @@ static void *unflatten_dt_node(const void *blob, void *mem, int *poffset,
*poffset = fdt_next_node(blob, *poffset, &depth);
if (depth < 0)
depth = 0;
- while (*poffset > 0 && depth > old_depth)
+ while (*poffset > 0 && depth > old_depth) {
mem = unflatten_dt_node(blob, mem, poffset, np, NULL,
fpsize, dryrun);
+ if (!mem)
+ return NULL;
+ }
if (*poffset < 0 && *poffset != -FDT_ERR_NOTFOUND) {
debug("unflatten: error %d processing FDT\n", *poffset);
@@ -286,6 +289,8 @@ static int unflatten_device_tree(const void *blob,
start = 0;
size = (unsigned long)unflatten_dt_node(blob, NULL, &start, NULL, NULL,
0, true);
+ if (!size)
+ return -EFAULT;
size = ALIGN(size, 4);
debug(" size is %lx, allocating...\n", size);