Re: sizeof *data, when data isn't initalized, is that right?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxx
> 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@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [C Programming]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

  Powered by Linux