lkml.org 
[lkml]   [2011]   [Apr]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Crash with kfree(null) on MacBook? kobject_set_name_vargs
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



\
 
 \ /
  Last update: 2011-04-27 16:05    [W:0.251 / U:0.208 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site