From: Peng Donglin Date: Wed, 24 Oct 2018 14:00:19 +0800 Subject: [U-Boot] spl: fix the new position of gd and stack Message-ID: <20181024060019.2992-1-dolinux.peng@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de If we enable CONFIG_SPL_SYS_MALLOC_SIMPLE and set CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN, the new gd and stack will inside malloc area,so there is a overwrite risk. We can place the new position of gd and stack under the malloc area to fix this issue. Signed-off-by: Peng Donglin --- common/spl/spl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/spl/spl.c b/common/spl/spl.c index 292e659c9a..e85a153869 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -628,7 +628,7 @@ ulong spl_relocate_stack_gd(void) } #endif /* Get stack position: use 8-byte alignment for ABI compliance */ - ptr = CONFIG_SPL_STACK_R_ADDR - roundup(sizeof(gd_t),16); + ptr -= roundup(sizeof(gd_t), 16); new_gd = (gd_t *)ptr; memcpy(new_gd, (void *)gd, sizeof(gd_t)); #if CONFIG_IS_ENABLED(DM) -- 2.17.1