diff options
author | Atish Patra <atish.patra@wdc.com> | 2020-06-18 18:51:50 -0700 |
---|---|---|
committer | Heinrich Schuchardt <xypron.glpk@gmx.de> | 2020-06-19 09:00:38 +0200 |
commit | 0d7c2913fdf71d74e0d6c710dcceaa29f3862d8c (patch) | |
tree | d92e35420112a3d9913448e870181571ee55bf2f /cmd | |
parent | 0b3a92dfa3639167e8d1e40f524b5b094fbcd357 (diff) | |
download | u-boot-0d7c2913fdf71d74e0d6c710dcceaa29f3862d8c.zip u-boot-0d7c2913fdf71d74e0d6c710dcceaa29f3862d8c.tar.gz u-boot-0d7c2913fdf71d74e0d6c710dcceaa29f3862d8c.tar.bz2 |
cmd: bootefi: Honor the address & size cells properties correctly
fdtdec_get_addr_size reads the uses a fixed value for address & size
cell properties which may not be correct always.
Use the auto variant of the function which automatically reads
#address-cells & #size-cells from parent and uses to read the "reg"
property.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
On 32 bit systems fdt_addr_t may be 4 bytes long but size is defined as
u64. Avoid filling the upper 4 bytes of the sizep parameter of
fdtdec_get_addr_size_auto_parent() with random bytes from the stack by
defining a separate variable fdt_size.
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/bootefi.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 0f6d0f7..ac713ca 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -189,16 +189,19 @@ static void efi_carve_out_dt_rsv(void *fdt) if (nodeoffset >= 0) { subnode = fdt_first_subnode(fdt, nodeoffset); while (subnode >= 0) { + fdt_addr_t fdt_addr, fdt_size; + /* check if this subnode has a reg property */ - addr = fdtdec_get_addr_size(fdt, subnode, "reg", - (fdt_size_t *)&size); + fdt_addr = fdtdec_get_addr_size_auto_parent( + fdt, nodeoffset, subnode, + "reg", 0, &fdt_size, false); /* * The /reserved-memory node may have children with * a size instead of a reg property. */ if (addr != FDT_ADDR_T_NONE && fdtdec_get_is_enabled(fdt, subnode)) - efi_reserve_memory(addr, size); + efi_reserve_memory(fdt_addr, fdt_size); subnode = fdt_next_subnode(fdt, subnode); } } |