1
0
mirror of https://xff.cz/git/u-boot/ synced 2025-09-01 16:52:14 +02:00

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: c9222a08b3 ("fdtdec: Implement fdtdec_add_reserved_memory()")
Signed-off-by: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Heiko Stuebner
2019-10-23 16:46:38 +02:00
committed by Simon Glass
parent 1dd49f577b
commit 086336a225
2 changed files with 3 additions and 1 deletions

View File

@@ -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;
}
}