From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tom Rini Date: Fri, 8 Nov 2019 10:32:59 -0500 Subject: [U-Boot] [PATCH] dlmalloc: calloc: fix zeroing early allocations In-Reply-To: <20191025192335.13498-1-simon.k.r.goldschmidt@gmail.com> References: <20191025192335.13498-1-simon.k.r.goldschmidt@gmail.com> Message-ID: <20191108153259.GG19317@bill-the-cat> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 > Reviewed-by: Tom Rini 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: