diff options
| author | Simon Goldschmidt <[email protected]> | 2019-05-03 21:19:03 +0200 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2019-05-09 19:52:55 -0400 |
| commit | 59bd796801cf6bf3fb4c27d8c2309c9b603838e3 (patch) | |
| tree | 37061f1a53275fcc7bd025b7e930b6c2abd8906f | |
| parent | 93e078807f2e31c25a6fbbb153f62652d75ffe0a (diff) | |
fdt_shrink_to_minimum: do not mark fdt space reserved unconditionally
This function merely relocates the fdt blob, so don't let it alter
it by adding reservations that didn't exist before.
Instead, if the memory used for the fdt blob has been reserved
before calling this function, ensure the relocated memory is
marked as reserved instead.
Reported-by: Keerthy <[email protected]>
Reported-by: Lokesh Vutla <[email protected]>
Signed-off-by: Simon Goldschmidt <[email protected]>
Reviewed-by: Lokesh Vutla <[email protected]>
| -rw-r--r-- | common/fdt_support.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/common/fdt_support.c b/common/fdt_support.c index ab08a0114fe..4e7cf6ebe98 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -597,6 +597,7 @@ int fdt_shrink_to_minimum(void *blob, uint extrasize) uint64_t addr, size; int total, ret; uint actualsize; + int fdt_memrsv = 0; if (!blob) return 0; @@ -606,6 +607,7 @@ int fdt_shrink_to_minimum(void *blob, uint extrasize) fdt_get_mem_rsv(blob, i, &addr, &size); if (addr == (uintptr_t)blob) { fdt_del_mem_rsv(blob, i); + fdt_memrsv = 1; break; } } @@ -627,10 +629,12 @@ int fdt_shrink_to_minimum(void *blob, uint extrasize) /* Change the fdt header to reflect the correct size */ fdt_set_totalsize(blob, actualsize); - /* Add the new reservation */ - ret = fdt_add_mem_rsv(blob, map_to_sysmem(blob), actualsize); - if (ret < 0) - return ret; + if (fdt_memrsv) { + /* Add the new reservation */ + ret = fdt_add_mem_rsv(blob, map_to_sysmem(blob), actualsize); + if (ret < 0) + return ret; + } return actualsize; } |
