[U-Boot] [PATCH] driver: fsl-mc: memset pointers after malloc

Stefan Roese sr at denx.de
Fri Oct 6 11:30:41 UTC 2017


On 06.10.2017 13:05, Prabhakar Kushwaha wrote:
> Memory allocated via malloc is not guaranteed to be zeroized.
> 
> So explicitly memset the memory allocated via malloc.
> 
> Signed-off-by: Prabhakar Kushwaha <prabhakar.kushwaha at nxp.com>
> ---
>   drivers/net/fsl-mc/mc.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c
> index 12dbcd8..c03d68f 100644
> --- a/drivers/net/fsl-mc/mc.c
> +++ b/drivers/net/fsl-mc/mc.c
> @@ -730,6 +730,7 @@ int mc_init(u64 mc_fw_addr, u64 mc_dpc_addr)
>   		printf(" No memory: malloc() failed\n");
>   		return -ENOMEM;
>   	}
> +	memset(root_mc_io, 0, sizeof(struct fsl_mc_io));

Why not use calloc() instead of malloc()? You can drop the memset()
then completely.

Thanks,
Stefan


More information about the U-Boot mailing list