From: Hubert CHAUMETTE <hubert.chaumette@wanadoo.fr>
To: Daniel Hilst Selli <danielhilst@gmail.com>,
"linux-c-programming@vger.kernel.org"
<linux-c-programming@vger.kernel.org>
Subject: Re: sizeof *data, when data isn't initalized, is that right?
Date: Thu, 22 Jan 2015 19:39:47 +0100 [thread overview]
Message-ID: <54C143F3.7020704@wanadoo.fr> (raw)
In-Reply-To: <54C13F4A.2020404@gmail.com>
Hi,
As I understand it, sizeof(*data) is the same as sizeof(struct mcp23s08_driver_data). There should be no pointer dereference here, so I would say it isn't an issue. That notation is quite confusing though.
Note that data is surrounded by parenthesis, at least in Linux 3.18, in gpio-mcp23s08.c
Regards,
Hubert
Le 22/01/2015 19:19, Daniel Hilst Selli a écrit :
> I came across this code:
>
> struct mcp23s08_driver_data *data;
> ...
> data = kzalloc(sizeof *data + chips * sizeof(struct mcp23s08),
> GFP_KERNEL);
>
>
> Since data wasn't initialized when `sizeof *data' is called, wasn't this a non-initialized pointer dereference?
>
> Cheers
> --
> To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2015-01-22 18:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-22 18:19 sizeof *data, when data isn't initalized, is that right? Daniel Hilst Selli
2015-01-22 18:38 ` Hubert CHAUMETTE
2015-01-22 18:39 ` Hubert CHAUMETTE [this message]
2015-01-23 7:33 ` Trevor Woerner
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=54C143F3.7020704@wanadoo.fr \
--to=hubert.chaumette@wanadoo.fr \
--cc=danielhilst@gmail.com \
--cc=linux-c-programming@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).