malloc_simple: fix malloc_ptr calculation
PATCH 1/1 malloc_simple: fix malloc_ptr calculation
The gd->malloc_ptr and the gd->malloc_limit are offsets to gd->malloc_base. But the addr variable contains the absolute address. The new_ptr must be:
addr + bytes - gd->malloc_base.
--- common/malloc_simple.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
common/malloc_simple.c +1 -1
@@ -32,7 +32,7 @@ void *memalign_simple(size_t align, size_t bytes)void *ptr; addr =ALIGN (gd->malloc_base + gd->malloc_ptr, align); - new_ptr = addr + bytes; + new_ptr = addr + bytes - gd->malloc_base;if (new_ptr > gd->malloc_limit)return NULL ; ptr =map_sysmem (addr, bytes);
Signature · 1 line
2.1.4
PATCH 1/1 malloc_simple: fix malloc_ptr calculation
Hi,
Quoted 5 lines · Philipp Rosenberger
The
gd->malloc_ptrand thegd->malloc_limitare offsets togd->malloc_base. But the addr variable contains the absolute address. Thenew_ptrmust be:
addr + bytes -gd->malloc_base.Signed-off-by Philipp Rosenberger <[email protected]>
You're right, good catch:
Regards,
Hans
Quoted 18 lines
--- common/malloc_simple.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)common/malloc_simple.c +1
-1@@ -32,7 +32,7 @@ void *memalign_simple(size_t align, size_t bytes)void *ptr; addr =ALIGN (gd->malloc_base + gd->malloc_ptr, align); - new_ptr = addr + bytes; + new_ptr = addr + bytes - gd->malloc_base;if (new_ptr > gd->malloc_limit)return NULL ; ptr =map_sysmem (addr, bytes);
Quoted 6 lines · Philipp Rosenberger
The
gd->malloc_ptrand thegd->malloc_limitare offsets togd->malloc_base. But the addr variable contains the absolute address. Thenew_ptrmust be:
addr + bytes -gd->malloc_base.Signed-off-by Philipp Rosenberger <[email protected]>Reviewed-by Hans de Goede <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150928/98dd2f33/attachment.sig>
Quoted 7 lines · Tom Rini
Quoted 5 lines · Philipp Rosenberger
The
gd->malloc_ptrand thegd->malloc_limitare offsets to gd ->malloc_base.
But the addr variable contains the absolute address. Thenew_ptrmust be:
addr + bytes -gd->malloc_base.
Just bisected down git master not booting on my RK3288 board anymore, turned out to be this patch. Reverting it on master makes for a much happier board...
I'll dig a bit deeper what's going on here now.
Signature · 2 lines
Sjoerd Simons Collabora Ltd.