From: Gerd Hoffmann Date: Tue, 21 Oct 2014 12:31:07 +0200 Subject: [U-Boot] [PATCH] fix get_ram_size memory corruption In-Reply-To: <20141021092755.BCA3938095D@gemini.denx.de> References: <20141021092755.BCA3938095D@gemini.denx.de> Message-ID: <1413887467-18799-1-git-send-email-kraxel@redhat.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de base[0] is saved, but never restored. 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. Signed-off-by: Gerd Hoffmann --- common/memsize.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/memsize.c b/common/memsize.c index 589400d..ad79ff1 100644 --- a/common/memsize.c +++ b/common/memsize.c @@ -48,7 +48,9 @@ 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 (); -- 1.8.3.1