All of lore.kernel.org
 help / color / mirror / Atom feed
From: der.herr@hofr.at (Nicholas Mc Guire)
To: cocci@systeme.lip6.fr
Subject: [Cocci] simple scanner question
Date: Fri, 27 Dec 2013 10:46:34 +0100	[thread overview]
Message-ID: <20131227094634.GA10062@opentech.at> (raw)


HI !

 Trying to scan for a problem that was recently found in the acpi code.

<snip>
static void advance_transaction(struct acpi_ec *ec, u8 status)
{
        unsigned long flags;
        struct transaction *t = ec->curr;

        spin_lock_irqsave(&ec->lock, flags);
        if (!t)
                goto unlock;
        if (t->wlen > t->wi) {
<snip>

 the problem being that there is a race beween assignment of *t and aquiring
 the lock in the ec structure.

 What I thought should do was:

@assign@
expression s,var;
position p1,p2,p3;
statement S1;
identifier func,member;
@@

...func at p1(...){
...
 var = s->member at p2;
...
 spin_lock_irqsave at p3(s->lock,...);
 if(!var)
  S1
 ...
}

@script:python@
p1 << assign.p1;
p2 << assign.p2;
p3 << assign.p3;
fn << assign.func;
@@

print "%s:%s possible assign without lock at lines %s (related ? lock at line %s)" % (p1[0].file,fn,p2[0].line,p3[0].line)

but this simply does not trigger in the above code snippet. 

 root@rtl15:/usr/src/3.12.5-rt7# spatch -sp_file race3.cocci drivers/acpi/ec.c
 init_defs_builtins: /usr/local/share/coccinelle/standard.h
 HANDLING: drivers/acpi/ec.c

Can someone point me to my missunderstanding of coccinelle ?

thx!
hofrat

             reply	other threads:[~2013-12-27  9:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-27  9:46 Nicholas Mc Guire [this message]
2013-12-27 10:22 ` [Cocci] simple scanner question Julia Lawall
2013-12-27 10:37   ` Nicholas Mc Guire

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=20131227094634.GA10062@opentech.at \
    --to=der.herr@hofr.at \
    --cc=cocci@systeme.lip6.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.