aboutsummaryrefslogtreecommitdiff
path: root/lib/fdtdec.c
diff options
context:
space:
mode:
authorHeiko Stuebner <heiko.stuebner@theobroma-systems.com>2019-10-23 16:46:38 +0200
committerSimon Glass <sjg@chromium.org>2019-11-14 07:09:34 -0600
commit086336a22508affb7567bf6d383642554eda5a56 (patch)
tree9a0302a6f5f0218774d58119401c6b243ea29cfa /lib/fdtdec.c
parent1dd49f577b75d9d6d1716b133024a31d20748382 (diff)
downloadu-boot-086336a22508affb7567bf6d383642554eda5a56.zip
u-boot-086336a22508affb7567bf6d383642554eda5a56.tar.gz
u-boot-086336a22508affb7567bf6d383642554eda5a56.tar.bz2
fdtdec: protect against another NULL phandlep in fdtdec_add_reserved_memory()
The change adding fdtdec_add_reserved_memory() already protected the added phandle against the phandlep being NULL - making the phandlep var optional. But in the early code checking for an already existing carveout this check was not done and thus the phandle assignment could run into trouble, so add a check there as well, which makes the function still return successfully if a matching region is found, even though no-one wants to work with the phandle. Fixes: c9222a08b3f7 ("fdtdec: Implement fdtdec_add_reserved_memory()") Signed-off-by: Heiko Stuebner <heiko.stuebner@theobroma-systems.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'lib/fdtdec.c')
-rw-r--r--lib/fdtdec.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 125d9db..38a0cff 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -1309,7 +1309,8 @@ int fdtdec_add_reserved_memory(void *blob, const char *basename,
}
if (addr == carveout->start && (addr + size) == carveout->end) {
- *phandlep = fdt_get_phandle(blob, node);
+ if (phandlep)
+ *phandlep = fdt_get_phandle(blob, node);
return 0;
}
}