mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@lip6.fr>
To: Himangi Saraogi <himangi774@gmail.com>
Cc: Joe Perches <joe@perches.com>,
	Julia Lawall <Julia.Lawall@lip6.fr>,
	Gilles Muller <Gilles.Muller@lip6.fr>,
	Nicolas Palix <nicolas.palix@imag.fr>,
	Michal Marek <mmarek@suse.cz>,
	cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Coccinelle : Script to detect cast after memory allocation
Date: Sat, 14 Jun 2014 21:37:23 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.02.1406142136480.2018@localhost6.localdomain6> (raw)
In-Reply-To: <CAB78YHwDpK988sKk5pzXWhuMszyyS=wtk5ETP-B-JBGdwRPxhw@mail.gmail.com>

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

On Sun, 15 Jun 2014, Himangi Saraogi wrote:

> Hi,
> 
> I have run the generic rule but it does not detect the cases of
> cast where the k[mzc]alloc or the kmem functions are used. I have used
> flags like recursive-includes, as suggested by Julia, but not any of the
> cases covered by the original script are detected.

Are other things detected?  You could always expand the rule to be more 
comprehensive.

julia


> Thanks
> Himangi
> 
> 
> On 14 June 2014 22:31, Joe Perches <joe@perches.com> wrote:
>       On Sat, 2014-06-14 at 18:11 +0200, Julia Lawall wrote:
>       > On Sat, 14 Jun 2014, Joe Perches wrote:
> []
> > > Perhaps make this more generic for any void *?
> > >
> > > Something like:
> > >
> > > @@
> > > void *t;
> > > type other;
> > > @@
> > >
> > > -       (other *)t
> > > +       t
> []
> > Perhaps it would be reasonable to add this among the specific
> functions.
> > That is, t could be part of the disjunctions.
> 
> You do have to make sure that the
> "casted to" type is not dereferenced.
> 
> ie: don't transform
> 
> void func(void *foo)
> {
>         unsigned long bar = *(unsigned long *)foo;
> }
> 
> Also there may be some __user cast types and
> such that may be necessary to exclude too.
> 
> 
> 
> 
> 
> 

  parent reply	other threads:[~2014-06-14 19:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-14 15:45 Himangi Saraogi
2014-06-14 16:06 ` Joe Perches
2014-06-14 16:11   ` Julia Lawall
2014-06-14 17:01     ` Joe Perches
     [not found]       ` <CAB78YHwDpK988sKk5pzXWhuMszyyS=wtk5ETP-B-JBGdwRPxhw@mail.gmail.com>
2014-06-14 19:37         ` Julia Lawall [this message]
2014-06-14 20:03         ` Joe Perches

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.1406142136480.2018@localhost6.localdomain6 \
    --to=julia.lawall@lip6.fr \
    --cc=Gilles.Muller@lip6.fr \
    --cc=cocci@systeme.lip6.fr \
    --cc=himangi774@gmail.com \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mmarek@suse.cz \
    --cc=nicolas.palix@imag.fr \
    /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

all inboxes | Powered by JetHome®