From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from acsinet15.oracle.com ([141.146.126.227]:50820 "EHLO acsinet15.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751946Ab2DUMnE (ORCPT ); Sat, 21 Apr 2012 08:43:04 -0400 Date: Sat, 21 Apr 2012 15:45:23 +0300 From: Dan Carpenter To: Kalle Valo Cc: Julian Calaby , "John W. Linville" , linux-wireless@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [patch] wireless: at76c50x: allocating too much data Message-ID: <20120421124523.GS6498@mwanda> (sfid-20120421_144309_032325_BCC732AF) References: <20120420064705.GE22649@elgon.mountain> <20120420091449.GI27101@mwanda> <87vcku9sob.fsf@purkki.adurom.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 In-Reply-To: <87vcku9sob.fsf@purkki.adurom.net> Sender: linux-wireless-owner@vger.kernel.org List-ID: On Fri, Apr 20, 2012 at 09:14:44PM +0300, Kalle Valo wrote: > Dan Carpenter writes: > > > On Fri, Apr 20, 2012 at 06:57:00PM +1000, Julian Calaby wrote: > >> > -       struct mib_local *m = kmalloc(sizeof(struct mib_phy), GFP_KERNEL); > >> > +       struct mib_local *m = kmalloc(sizeof(struct mib_local), GFP_KERNEL); > >> > >> Would it be better practice to use sizeof(*m)? > >> > > > > That was my temptation as well... But I decided to make it match > > with the surrounding code. I'm happy to resend if people want. > > IMHO sizeof(*m) is better and I tend to use it. > > Related to this: I have a bad habit of sometimes dropping '*' from > sizeof()? Is there a tool which could spot that? > That's what I was working on for Smatch when I sent this patch. The odd thing is that I can't find any bugs like this in the kernel. If sizeof(foo) is less than sizeof(*foo), which is probably the normal case, then these get caught early on in testing. Still I think people must have done manual audits as well... It feels too clean to be natural. regards, dan carpenter From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Carpenter Date: Sat, 21 Apr 2012 12:45:23 +0000 Subject: Re: [patch] wireless: at76c50x: allocating too much data Message-Id: <20120421124523.GS6498@mwanda> List-Id: References: <20120420064705.GE22649@elgon.mountain> <20120420091449.GI27101@mwanda> <87vcku9sob.fsf@purkki.adurom.net> In-Reply-To: <87vcku9sob.fsf@purkki.adurom.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: Kalle Valo Cc: Julian Calaby , "John W. Linville" , linux-wireless@vger.kernel.org, kernel-janitors@vger.kernel.org On Fri, Apr 20, 2012 at 09:14:44PM +0300, Kalle Valo wrote: > Dan Carpenter writes: >=20 > > On Fri, Apr 20, 2012 at 06:57:00PM +1000, Julian Calaby wrote: > >> > - =A0 =A0 =A0 struct mib_local *m =3D kmalloc(sizeof(struct mib_phy)= , GFP_KERNEL); > >> > + =A0 =A0 =A0 struct mib_local *m =3D kmalloc(sizeof(struct mib_loca= l), GFP_KERNEL); > >>=20 > >> Would it be better practice to use sizeof(*m)? > >>=20 > > > > That was my temptation as well... But I decided to make it match > > with the surrounding code. I'm happy to resend if people want. >=20 > IMHO sizeof(*m) is better and I tend to use it. >=20 > Related to this: I have a bad habit of sometimes dropping '*' from > sizeof()? Is there a tool which could spot that? >=20 That's what I was working on for Smatch when I sent this patch. The odd thing is that I can't find any bugs like this in the kernel. If sizeof(foo) is less than sizeof(*foo), which is probably the normal case, then these get caught early on in testing. Still I think people must have done manual audits as well... It feels too clean to be natural. regards, dan carpenter -- To unsubscribe from this list: send the line "unsubscribe kernel-janitors" = in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html