[U-Boot] [PATCH] part_efi: fix protective_mbr struct allocation

Fabio Estevam festevam at gmail.com
Wed Feb 12 15:43:02 CET 2014


On Wed, Feb 12, 2014 at 12:40 PM, Hector Palacios
<hector.palacios at digi.com> wrote:
> The calloc() call was allocating space for the sizeof the struct
> pointer rather than for the struct contents.
>
> Signed-off-by: Hector Palacios <hector.palacios at digi.com>
> ---
>  disk/part_efi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/disk/part_efi.c b/disk/part_efi.c
> index 5dfaf490c89a..7fabec059d7a 100644
> --- a/disk/part_efi.c
> +++ b/disk/part_efi.c
> @@ -232,7 +232,7 @@ static int set_protective_mbr(block_dev_desc_t *dev_desc)
>         legacy_mbr *p_mbr;
>
>         /* Setup the Protective MBR */
> -       p_mbr = calloc(1, sizeof(p_mbr));
> +       p_mbr = calloc(1, sizeof(legacy_mbr));

What about:

p_mbr = calloc(1, sizeof(*p_mbr)) ?


Regards,

Fabio Estevam


More information about the U-Boot mailing list