[U-Boot] [PATCH v3] fix get_ram_size memory corruption
Gerd Hoffmann
kraxel at redhat.com
Tue Oct 21 14:28:24 CEST 2014
base[0] is saved, but only restored in case the ram test failed.
Test case: Start u-boot in qemu, using vexpress-a9 emulation.
qemu places the fdt at the start of ram, as a service for the
guest. Trying to pick it up there by setting fdt_addr
accordingly fails because the fdt magic cookie is gone (zeroed
out) after calling get_ram_size.
Cc: Wolfgang Denk <wd at denx.de>
Signed-off-by: Gerd Hoffmann <kraxel at redhat.com>
---
common/memsize.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/common/memsize.c b/common/memsize.c
index 589400d..dac1368 100644
--- a/common/memsize.c
+++ b/common/memsize.c
@@ -48,11 +48,12 @@ long get_ram_size(long *base, long maxsize)
*addr = 0;
sync ();
- if ((val = *addr) != 0) {
+ val = *addr;
+ *addr = save[i];
+ if (val != 0) {
/* Restore the original data before leaving the function.
*/
sync ();
- *addr = save[i];
for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
addr = base + cnt;
sync ();
--
1.8.3.1
More information about the U-Boot
mailing list