linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@lip6.fr>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Kalle Valo <kvalo@adurom.com>,
	Julian Calaby <julian.calaby@gmail.com>,
	"John W. Linville" <linville@tuxdriver.com>,
	linux-wireless@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] wireless: at76c50x: allocating too much data
Date: Sat, 21 Apr 2012 15:51:44 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.02.1204211548090.1987@hadrien> (raw)
In-Reply-To: <20120421124523.GS6498@mwanda>

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1483 bytes --]

On Sat, 21 Apr 2012, Dan Carpenter wrote:

> On Fri, Apr 20, 2012 at 09:14:44PM +0300, Kalle Valo wrote:
>> Dan Carpenter <dan.carpenter@oracle.com> 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.

Looking for x = ... sizeof(x) ... I get 9 reports.  In most cases it looks 
like sizeof(x) is coincidentally the same as the size that is wanted.  Two 
cases that look like they could have some noticible effect are:

arch/xtensa/platforms/iss/network.c, line 789
drivers/block/cciss.c, line 4211

I will send patches for those two.

julia

  parent reply	other threads:[~2012-04-21 13:51 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-20  6:47 [patch] wireless: at76c50x: allocating too much data Dan Carpenter
2012-04-20  8:57 ` Julian Calaby
2012-04-20  9:14   ` Dan Carpenter
2012-04-20 18:14     ` Kalle Valo
2012-04-21 12:23       ` [patch v2] " Dan Carpenter
2012-04-21 12:45       ` [patch] " Dan Carpenter
2012-04-21 13:19         ` Julia Lawall
2012-04-21 13:51         ` Julia Lawall [this message]
2012-04-21 14:51           ` Dan Carpenter
2012-04-21 14:51             ` Julia Lawall
2012-04-21 14:59             ` Dan Carpenter
2012-04-21 15:12             ` Dan Carpenter
2012-04-21 15:13               ` Julia Lawall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.02.1204211548090.1987@hadrien \
    --to=julia.lawall@lip6.fr \
    --cc=dan.carpenter@oracle.com \
    --cc=julian.calaby@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kvalo@adurom.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).