Re: Crash with kfree(null) on MacBook? kobject_set_name_vargs

From: Steven Rostedt
Date: Wed Apr 27 2011 - 10:03:40 EST


On Mon, Apr 11, 2011 at 09:38:02PM +0200, Rafa?? Mi??ecki wrote:
> Thank you Linus, now when you made it clear to me that NULL ~!= NULL,
> I realized I didn't zeroed struct which contains struct dev.
>
> struct axi_device core;
> vs.
> struct axi_device core = { };

The two are identical. If they are declared as globals or static. As
globals and static variables are initialized to zero at start up.

Is this on the stack or global? If on the stack, you need the
initializer, if it is global you do not.

IOW:

struct axi_device core;
static struct axi_device core;

void func(void)
{
static struct axi_device core;
[...]

All the above is OK with no initializer.

void func(void)
{
struct axi_device core = {};


This does need an initializer, but gcc should complain if you use core
without initializing.

-- Steve

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/