From: Tom Rini <trini@konsulko.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] dlmalloc: calloc: fix zeroing early allocations
Date: Fri, 8 Nov 2019 10:32:59 -0500 [thread overview]
Message-ID: <20191108153259.GG19317@bill-the-cat> (raw)
In-Reply-To: <20191025192335.13498-1-simon.k.r.goldschmidt@gmail.com>
On Fri, Oct 25, 2019 at 09:23:35PM +0200, Simon Goldschmidt wrote:
> When full malloc is enabled and SYS_MALLOC_F is also enabled, the simple
> pre-reloc heap is used before relocation. In this case, calloc() uses
> the MALLOC_ZERO macro to zero out the allocated memory. However, since
> this macro is specially crafted for the dlmalloc implementation, it
> does not always work for simple malloc.
>
> For example, when allocating 16 bytes via simple malloc, only the first
> 12 bytes get zeroed out. The last 4 bytes will remain untouched.
>
> This is a problem for DM drivers that are allocated before relocation:
> memory allocated via 'platdata_auto_alloc_size' might not be set to
> zero, resulting in bogus behaviour.
>
> To fix this, use 'memset' instead of 'MALLOC_ZERO' to zero out memory
> that compes from simple malloc.
>
> Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
> Reviewed-by: Tom Rini <trini@konsulko.com>
Applied to u-boot/master, thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20191108/75a20b2d/attachment.sig>
prev parent reply other threads:[~2019-11-08 15:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-25 19:23 [U-Boot] [PATCH] dlmalloc: calloc: fix zeroing early allocations Simon Goldschmidt
2019-10-30 17:01 ` Tom Rini
2019-11-08 15:32 ` Tom Rini [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191108153259.GG19317@bill-the-cat \
--to=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox