From: Albert ARIBAUD <albert.u.boot@aribaud.net>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] part_efi: fix protective_mbr struct allocation
Date: Wed, 12 Feb 2014 17:33:29 +0100 [thread overview]
Message-ID: <20140212173329.057a0c87@lilith> (raw)
In-Reply-To: <CAOMZO5Azo_w5sjP3GD8_WoAx=NXO6thFdFiNBwGHYO0DiNSJ1Q@mail.gmail.com>
Hi Fabio,
On Wed, 12 Feb 2014 12:43:02 -0200, Fabio Estevam <festevam@gmail.com>
wrote:
> On Wed, Feb 12, 2014 at 12:40 PM, Hector Palacios
> <hector.palacios@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@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)) ?
I don't like the idea of setting p_mbr based on *p_mbr at a time where
p_mbr is still undefined. I know that from a C standard perspective
this is ok, but I'd rather simply not run any risk and pass sizeof
the struct type, not a (non-existent) dereferenced 'value'.
> Regards,
>
> Fabio Estevam
Amicalement,
--
Albert.
next prev parent reply other threads:[~2014-02-12 16:33 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-12 14:40 [U-Boot] [PATCH] part_efi: fix protective_mbr struct allocation Hector Palacios
2014-02-12 14:43 ` Fabio Estevam
2014-02-12 16:33 ` Albert ARIBAUD [this message]
2014-02-12 17:33 ` Fabio Estevam
2014-02-12 17:58 ` Albert ARIBAUD
2014-02-12 15:55 ` Lukasz Majewski
2014-02-12 16:24 ` Palacios, Hector
2014-02-12 16:30 ` Albert ARIBAUD
2014-02-12 16:48 ` Palacios, Hector
2014-02-12 20:45 ` Lukasz Majewski
2014-02-13 2:23 ` Albert ARIBAUD
2014-02-19 8:19 ` Lukasz Majewski
2014-02-19 10:08 ` Albert ARIBAUD
2014-02-19 10:15 ` Albert ARIBAUD
2014-02-19 12:52 ` Palacios, Hector
2014-02-19 14:14 ` Albert ARIBAUD
2014-02-19 14:25 ` Lukasz Majewski
2014-02-19 14:38 ` Albert ARIBAUD
2014-02-19 15:11 ` Lukasz Majewski
2014-02-19 14:22 ` Tom Rini
2014-02-19 15:10 ` Lukasz Majewski
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=20140212173329.057a0c87@lilith \
--to=albert.u.boot@aribaud.net \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.