Skip to contentSkip to conversation

malloc_simple: Correct the alignment logic in memalign_simple()

PATCH In review Simon Glass 2 participants 3 messages Aug 14, 2015 – Aug 28, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 malloc_simple: Correct the alignment logic in memalign_simple()

This should use the align parameter, not bytes. Natural alignment is one use case but should not be the only one supported by this function.

---

 common/malloc_simple.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/malloc_simple.c +1 -1
index 9811ab6..134e059 100644
@@ -31,7 +31,7 @@ void *memalign_simple(size_t align, size_t bytes)
 	ulong addr, new_ptr;
 	void *ptr;
 
-	addr = ALIGN(gd->malloc_base + gd->malloc_ptr, bytes);
+	addr = ALIGN(gd->malloc_base + gd->malloc_ptr, align);
 	new_ptr = addr + bytes;
 	if (new_ptr > gd->malloc_limit)
 		return NULL;
Signature · 1 line
2.5.0.276.gf5e568e
#1 lore raw

PATCH 1/1 malloc_simple: Correct the alignment logic in memalign_simple()

Quoted 4 lines · Simon Glass

This should use the align parameter, not bytes. Natural alignment is one use case but should not be the only one supported by this function.

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/20150814/bc54027d/attachment.sig>
#2 lore raw
In reply to Simon Glass
Quoted 5 lines · Simon Glass

This should use the align parameter, not bytes. Natural alignment is one use case but should not be the only one supported by this function.

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/20150828/f981789b/attachment.sig>