mirror of
https://github.com/u-boot/u-boot.git
synced 2024-11-27 06:04:40 +08:00
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 <j-keerthy@ti.com> Reported-by: Lokesh Vutla <lokeshvutla@ti.com> Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com> Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>
This commit is contained in:
parent
93e078807f
commit
59bd796801
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user