From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932963Ab1D0ODh (ORCPT ); Wed, 27 Apr 2011 10:03:37 -0400 Received: from hrndva-omtalb.mail.rr.com ([71.74.56.122]:46561 "EHLO hrndva-omtalb.mail.rr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932894Ab1D0ODf (ORCPT ); Wed, 27 Apr 2011 10:03:35 -0400 X-Authority-Analysis: v=1.1 cv=ZtuXOl23UuD1yoJUTgnZ6i6Z5VPlPhPMWCeUNtN8OGA= c=1 sm=0 a=XYJHFtupD_QA:10 a=yvBG9YuN2l4A:10 a=5SG0PmZfjMsA:10 a=kj9zAlcOel0A:10 a=OPBmh+XkhLl+Enan7BmTLg==:17 a=3J4kajBME3dDW4uYzyAA:9 a=wTwojRmyW5iaIv-n99kA:7 a=CjuIK1q_8ugA:10 a=OPBmh+XkhLl+Enan7BmTLg==:117 X-Cloudmark-Score: 0 X-Originating-IP: 67.242.120.143 Date: Wed, 27 Apr 2011 10:03:33 -0400 From: Steven Rostedt To: Rafa?? Mi??ecki Cc: Linus Torvalds , Linux Kernel Mailing List , Andy Botting Subject: Re: Crash with kfree(null) on MacBook? kobject_set_name_vargs Message-ID: <20110427140333.GA22909@home.goodmis.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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