All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scripts: Coccinelle script for pci_free_consistent()
@ 2013-04-28 17:04 strnape1
  2013-04-28 23:05 ` Julia Lawall
                   ` (15 more replies)
  0 siblings, 16 replies; 31+ messages in thread
From: strnape1 @ 2013-04-28 17:04 UTC (permalink / raw)
  To: kernel-janitors

Created coccinelle script for reporting missing pci_free_consistent() calls.

Signed-off-by: Petr Strnad <strnape1@fel.cvut.cz>
---
diff --git a/scripts/coccinelle/free/pci_free_consistent.cocci  
b/scripts/coccinelle/free/pci_free_consistent.cocci
new file mode 100644
index 0000000..08ea45a
--- /dev/null
+++ b/scripts/coccinelle/free/pci_free_consistent.cocci
@@ -0,0 +1,36 @@
+/// Find missing pci_free_consistent for every pci_alloc_consistent.
+///
+// Copyright: (C) 2013 Petr Strnad.  GPLv2.
+// URL: http://coccinelle.lip6.fr/
+//
+// Keywords: pci_free_consisten, pci_alloc_consistent
+//
+
+virtual context
+virtual patch
+virtual org
+virtual report
+
+@search@
+expression id,x,y,z;
+position p1,p2;
+@@
+
+<...
+id = pci_alloc_consistent@p1(x,y,z)
+... when != pci_free_consistent(x,y,id,z)
+    when forall
+(
+if (id = NULL) { ... }
+|
+*return@p2 ...;
+)
+...>
+
+@script:python depends on report@
+p1 << search.p1;
+p2 << search.p2;
+@@
+
+msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on  
line %s and return without freeing on line %s" % (p1[0].line,p2[0].line)
+coccilib.report.print_report(p2[0],msg)


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [PATCH] scripts: Coccinelle script for pci_free_consistent()
  2013-04-28 17:04 [PATCH] scripts: Coccinelle script for pci_free_consistent() strnape1
@ 2013-04-28 23:05 ` Julia Lawall
  2013-04-29 21:06 ` strnape1
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 31+ messages in thread
From: Julia Lawall @ 2013-04-28 23:05 UTC (permalink / raw)
  To: kernel-janitors

Actually, you don't support org or patch mode.  So you should get rid of
the corresponding virtual declarations at the top of the rule.  You could
also add an Options line at the top with --no-includes --include-headers,
since you don't need to include any header files for this rule, but the
rule might apply within a header file.

julia

On Sun, 28 Apr 2013, strnape1@fel.cvut.cz wrote:

> Created coccinelle script for reporting missing pci_free_consistent() calls.
>
> Signed-off-by: Petr Strnad <strnape1@fel.cvut.cz>
> ---
> diff --git a/scripts/coccinelle/free/pci_free_consistent.cocci
> b/scripts/coccinelle/free/pci_free_consistent.cocci
> new file mode 100644
> index 0000000..08ea45a
> --- /dev/null
> +++ b/scripts/coccinelle/free/pci_free_consistent.cocci
> @@ -0,0 +1,36 @@
> +/// Find missing pci_free_consistent for every pci_alloc_consistent.
> +///
> +// Copyright: (C) 2013 Petr Strnad.  GPLv2.
> +// URL: http://coccinelle.lip6.fr/
> +//
> +// Keywords: pci_free_consisten, pci_alloc_consistent
> +//
> +
> +virtual context
> +virtual patch
> +virtual org
> +virtual report
> +
> +@search@
> +expression id,x,y,z;
> +position p1,p2;
> +@@
> +
> +<...
> +id = pci_alloc_consistent@p1(x,y,z)
> +... when != pci_free_consistent(x,y,id,z)
> +    when forall
> +(
> +if (id = NULL) { ... }
> +|
> +*return@p2 ...;
> +)
> +...>
> +
> +@script:python depends on report@
> +p1 << search.p1;
> +p2 << search.p2;
> +@@
> +
> +msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on line %s
> and return without freeing on line %s" % (p1[0].line,p2[0].line)
> +coccilib.report.print_report(p2[0],msg)
>
> --
> 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

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] scripts: Coccinelle script for pci_free_consistent()
  2013-04-28 17:04 [PATCH] scripts: Coccinelle script for pci_free_consistent() strnape1
  2013-04-28 23:05 ` Julia Lawall
@ 2013-04-29 21:06 ` strnape1
  2013-04-29 23:35 ` Julia Lawall
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 31+ messages in thread
From: strnape1 @ 2013-04-29 21:06 UTC (permalink / raw)
  To: kernel-janitors

Should I resubmit the patch with the proper file, or create a patch to  
"patch" the one I already submited then?
Quoting Julia Lawall <julia.lawall@lip6.fr>:

> Actually, you don't support org or patch mode.  So you should get rid of
> the corresponding virtual declarations at the top of the rule.  You could
> also add an Options line at the top with --no-includes --include-headers,
> since you don't need to include any header files for this rule, but the
> rule might apply within a header file.
>
> julia
>
> On Sun, 28 Apr 2013, strnape1@fel.cvut.cz wrote:
>
>> Created coccinelle script for reporting missing pci_free_consistent() calls.
>>
>> Signed-off-by: Petr Strnad <strnape1@fel.cvut.cz>
>> ---
>> diff --git a/scripts/coccinelle/free/pci_free_consistent.cocci
>> b/scripts/coccinelle/free/pci_free_consistent.cocci
>> new file mode 100644
>> index 0000000..08ea45a
>> --- /dev/null
>> +++ b/scripts/coccinelle/free/pci_free_consistent.cocci
>> @@ -0,0 +1,36 @@
>> +/// Find missing pci_free_consistent for every pci_alloc_consistent.
>> +///
>> +// Copyright: (C) 2013 Petr Strnad.  GPLv2.
>> +// URL: http://coccinelle.lip6.fr/
>> +//
>> +// Keywords: pci_free_consisten, pci_alloc_consistent
>> +//
>> +
>> +virtual context
>> +virtual patch
>> +virtual org
>> +virtual report
>> +
>> +@search@
>> +expression id,x,y,z;
>> +position p1,p2;
>> +@@
>> +
>> +<...
>> +id = pci_alloc_consistent@p1(x,y,z)
>> +... when != pci_free_consistent(x,y,id,z)
>> +    when forall
>> +(
>> +if (id = NULL) { ... }
>> +|
>> +*return@p2 ...;
>> +)
>> +...>
>> +
>> +@script:python depends on report@
>> +p1 << search.p1;
>> +p2 << search.p2;
>> +@@
>> +
>> +msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on line %s
>> and return without freeing on line %s" % (p1[0].line,p2[0].line)
>> +coccilib.report.print_report(p2[0],msg)
>>
>> --
>> 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




^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] scripts: Coccinelle script for pci_free_consistent()
  2013-04-28 17:04 [PATCH] scripts: Coccinelle script for pci_free_consistent() strnape1
  2013-04-28 23:05 ` Julia Lawall
  2013-04-29 21:06 ` strnape1
@ 2013-04-29 23:35 ` Julia Lawall
  2013-04-30  7:58 ` strnape1
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 31+ messages in thread
From: Julia Lawall @ 2013-04-29 23:35 UTC (permalink / raw)
  To: kernel-janitors

On Mon, 29 Apr 2013, strnape1@fel.cvut.cz wrote:

> Should I resubmit the patch with the proper file, or create a patch to "patch"
> the one I already submited then?

You can resubmit.

thanks,
julia

> Quoting Julia Lawall <julia.lawall@lip6.fr>:
>
> > Actually, you don't support org or patch mode.  So you should get rid of
> > the corresponding virtual declarations at the top of the rule.  You could
> > also add an Options line at the top with --no-includes --include-headers,
> > since you don't need to include any header files for this rule, but the
> > rule might apply within a header file.
> >
> > julia
> >
> > On Sun, 28 Apr 2013, strnape1@fel.cvut.cz wrote:
> >
> > > Created coccinelle script for reporting missing pci_free_consistent()
> > > calls.
> > >
> > > Signed-off-by: Petr Strnad <strnape1@fel.cvut.cz>
> > > ---
> > > diff --git a/scripts/coccinelle/free/pci_free_consistent.cocci
> > > b/scripts/coccinelle/free/pci_free_consistent.cocci
> > > new file mode 100644
> > > index 0000000..08ea45a
> > > --- /dev/null
> > > +++ b/scripts/coccinelle/free/pci_free_consistent.cocci
> > > @@ -0,0 +1,36 @@
> > > +/// Find missing pci_free_consistent for every pci_alloc_consistent.
> > > +///
> > > +// Copyright: (C) 2013 Petr Strnad.  GPLv2.
> > > +// URL: http://coccinelle.lip6.fr/
> > > +//
> > > +// Keywords: pci_free_consisten, pci_alloc_consistent
> > > +//
> > > +
> > > +virtual context
> > > +virtual patch
> > > +virtual org
> > > +virtual report
> > > +
> > > +@search@
> > > +expression id,x,y,z;
> > > +position p1,p2;
> > > +@@
> > > +
> > > +<...
> > > +id = pci_alloc_consistent@p1(x,y,z)
> > > +... when != pci_free_consistent(x,y,id,z)
> > > +    when forall
> > > +(
> > > +if (id = NULL) { ... }
> > > +|
> > > +*return@p2 ...;
> > > +)
> > > +...>
> > > +
> > > +@script:python depends on report@
> > > +p1 << search.p1;
> > > +p2 << search.p2;
> > > +@@
> > > +
> > > +msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on line
> > > %s
> > > and return without freeing on line %s" % (p1[0].line,p2[0].line)
> > > +coccilib.report.print_report(p2[0],msg)
> > >
> > > --
> > > 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
>
>
>

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH] scripts: Coccinelle script for pci_free_consistent()
  2013-04-28 17:04 [PATCH] scripts: Coccinelle script for pci_free_consistent() strnape1
                   ` (2 preceding siblings ...)
  2013-04-29 23:35 ` Julia Lawall
@ 2013-04-30  7:58 ` strnape1
  2013-05-01 10:32 ` Julia Lawall
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 31+ messages in thread
From: strnape1 @ 2013-04-30  7:58 UTC (permalink / raw)
  To: kernel-janitors

Created coccinelle script for reporting missing pci_free_consistent() calls.

Signed-off-by: Petr Strnad <strnape1@fel.cvut.cz>
---
diff --git a/scripts/coccinelle/free/pci_free_consistent.cocci  
b/scripts/coccinelle/free/pci_free_consistent.cocci
new file mode 100644
index 0000000..1196485
--- /dev/null
+++ b/scripts/coccinelle/free/pci_free_consistent.cocci
@@ -0,0 +1,32 @@
+/// Find missing pci_free_consistent for every pci_alloc_consistent.
+///
+// Copyright: (C) 2013 Petr Strnad.  GPLv2.
+// URL: http://coccinelle.lip6.fr/
+// Keywords: pci_free_consisten, pci_alloc_consistent
+// Options: --no-includes --include-headers
+
+virtual report
+
+@search@
+expression id,x,y,z;
+position p1,p2;
+@@
+
+<...
+id = pci_alloc_consistent@p1(x,y,z)
+... when != pci_free_consistent(x,y,id,z)
+    when forall
+(
+if (id = NULL) { ... }
+|
+*return@p2 ...;
+)
+...>
+
+@script:python depends on report@
+p1 << search.p1;
+p2 << search.p2;
+@@
+
+msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on  
line %s and return without freeing on line %s" % (p1[0].line,p2[0].line)
+coccilib.report.print_report(p2[0],msg)


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [PATCH] scripts: Coccinelle script for pci_free_consistent()
  2013-04-28 17:04 [PATCH] scripts: Coccinelle script for pci_free_consistent() strnape1
                   ` (3 preceding siblings ...)
  2013-04-30  7:58 ` strnape1
@ 2013-05-01 10:32 ` Julia Lawall
  2013-05-02  0:28 ` strnape1
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 31+ messages in thread
From: Julia Lawall @ 2013-05-01 10:32 UTC (permalink / raw)
  To: kernel-janitors

This has quite a lot of false positives.  For example in
drivers/firewire/nosy.c
at the return 0 just above the label fail_free_irq in the function
add_card.  Return 0 usually indicates success, and the allocated data is
usually saved somwhere before the success exit.  In nosy.c, the allocated
data is stored in a field of the lynx structure, and the lynx structure is
then stored in card_list, via a call to list_add_tail.

Maybe it would be sufficient not to mark a return with p2 when the return
does return 0.  You would thus have:

(
if (id = NULL) { ... }
|
return 0;
|
*return@p2 ...;
)

You might want to limit id to be a "local idexpression" instead of an
arbitrary expression.  If there is x->y = fn(...), x may be a parameter,
or may be a variable that is stored or freed in some other way, hiding the
call to pci_free_consistent.

Also, you don't need the <... ...> around the rule.

There is also a typo in your first keyword.

Anyway, you can make those changes and look at the result, and see what
the rate of false positives seems to be.  It would be good to put a
confidence level in your semantic patch as well.  You can see examples
in the Linux coccinelle directory.

julia

On Tue, 30 Apr 2013, strnape1@fel.cvut.cz wrote:

> Created coccinelle script for reporting missing pci_free_consistent() calls.
>
> Signed-off-by: Petr Strnad <strnape1@fel.cvut.cz>
> ---
> diff --git a/scripts/coccinelle/free/pci_free_consistent.cocci
> b/scripts/coccinelle/free/pci_free_consistent.cocci
> new file mode 100644
> index 0000000..1196485
> --- /dev/null
> +++ b/scripts/coccinelle/free/pci_free_consistent.cocci
> @@ -0,0 +1,32 @@
> +/// Find missing pci_free_consistent for every pci_alloc_consistent.
> +///
> +// Copyright: (C) 2013 Petr Strnad.  GPLv2.
> +// URL: http://coccinelle.lip6.fr/
> +// Keywords: pci_free_consisten, pci_alloc_consistent
> +// Options: --no-includes --include-headers
> +
> +virtual report
> +
> +@search@
> +expression id,x,y,z;
> +position p1,p2;
> +@@
> +
> +<...
> +id = pci_alloc_consistent@p1(x,y,z)
> +... when != pci_free_consistent(x,y,id,z)
> +    when forall
> +(
> +if (id = NULL) { ... }
> +|
> +*return@p2 ...;
> +)
> +...>
> +
> +@script:python depends on report@
> +p1 << search.p1;
> +p2 << search.p2;
> +@@
> +
> +msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on line %s
> and return without freeing on line %s" % (p1[0].line,p2[0].line)
> +coccilib.report.print_report(p2[0],msg)
>
> --
> 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

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH] scripts: Coccinelle script for pci_free_consistent()
  2013-04-28 17:04 [PATCH] scripts: Coccinelle script for pci_free_consistent() strnape1
                   ` (4 preceding siblings ...)
  2013-05-01 10:32 ` Julia Lawall
@ 2013-05-02  0:28 ` strnape1
  2013-05-02  0:57 ` Julia Lawall
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 31+ messages in thread
From: strnape1 @ 2013-05-02  0:28 UTC (permalink / raw)
  To: kernel-janitors

Created coccinelle script for reporting missing pci_free_consistent() calls.

Signed-off-by: Petr Strnad <strnape1@fel.cvut.cz>
---
diff --git a/scripts/coccinelle/free/pci_free_consistent.cocci  
b/scripts/coccinelle/free/pci_free_consistent.cocci
new file mode 100644
index 0000000..9d9a56f
--- /dev/null
+++ b/scripts/coccinelle/free/pci_free_consistent.cocci
@@ -0,0 +1,44 @@
+/// Find missing pci_free_consistent for every pci_alloc_consistent.
+///
+// Confidence: Moderate
+// Copyright: (C) 2013 Petr Strnad.  GPLv2.
+// URL: http://coccinelle.lip6.fr/
+// Keywords: pci_free_consistent, pci_alloc_consistent
+// Options: --no-includes --include-headers
+
+virtual report
+
+@search@
+local idexpression id;
+expression x,y,z;
+position p1,p2;
+@@
+
+id = pci_alloc_consistent@p1(x,y,&z)
+... when != pci_free_consistent(x,y,id,z)
+    when forall
+(
+if (id = NULL) { ... return ...; }
+|
+if (id = NULL || (unsigned long)id & 0xFF) { ... return ...; }
+|
+if (id = NULL) return ...;
+|
+if (id) { ... return 0; }
+|
+if (id) { ... } else { ... } return 0;
+|
+return 0;
+|
+return id;
+|
+*return@p2 ...;
+)
+
+@script:python depends on report@
+p1 << search.p1;
+p2 << search.p2;
+@@
+
+msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on  
line %s and return without freeing on line %s" % (p1[0].line,p2[0].line)
+coccilib.report.print_report(p2[0],msg)


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [PATCH] scripts: Coccinelle script for pci_free_consistent()
  2013-04-28 17:04 [PATCH] scripts: Coccinelle script for pci_free_consistent() strnape1
                   ` (5 preceding siblings ...)
  2013-05-02  0:28 ` strnape1
@ 2013-05-02  0:57 ` Julia Lawall
  2013-05-02 15:12 ` strnape1
                   ` (8 subsequent siblings)
  15 siblings, 0 replies; 31+ messages in thread
From: Julia Lawall @ 2013-05-02  0:57 UTC (permalink / raw)
  To: kernel-janitors

On Thu, 2 May 2013, strnape1@fel.cvut.cz wrote:

> Created coccinelle script for reporting missing pci_free_consistent() calls.
>
> Signed-off-by: Petr Strnad <strnape1@fel.cvut.cz>
> ---
> diff --git a/scripts/coccinelle/free/pci_free_consistent.cocci
> b/scripts/coccinelle/free/pci_free_consistent.cocci
> new file mode 100644
> index 0000000..9d9a56f
> --- /dev/null
> +++ b/scripts/coccinelle/free/pci_free_consistent.cocci
> @@ -0,0 +1,44 @@
> +/// Find missing pci_free_consistent for every pci_alloc_consistent.
> +///
> +// Confidence: Moderate
> +// Copyright: (C) 2013 Petr Strnad.  GPLv2.
> +// URL: http://coccinelle.lip6.fr/
> +// Keywords: pci_free_consistent, pci_alloc_consistent
> +// Options: --no-includes --include-headers
> +
> +virtual report
> +
> +@search@
> +local idexpression id;
> +expression x,y,z;
> +position p1,p2;
> +@@
> +
> +id = pci_alloc_consistent@p1(x,y,&z)
> +... when != pci_free_consistent(x,y,id,z)
> +    when forall
> +(
> +if (id = NULL) { ... return ...; }
> +|
> +if (id = NULL || (unsigned long)id & 0xFF) { ... return ...; }

The above two lines can be combined into if (id = NULL || ....) { ...
return ...; }

> +|
> +if (id = NULL) return ...;

This case shouldn't be necessary.  It should automatically consider { ...
return ...; } as also matching return ...; (isomorphism).

> +|
> +if (id) { ... return 0; }
> +|
> +if (id) { ... } else { ... } return 0;

Here, I would put S1 and S2, declared as statement metavariables, rather
than { ... }

julia

> +|
> +return 0;
> +|
> +return id;
> +|
> +*return@p2 ...;
> +)
> +
> +@script:python depends on report@
> +p1 << search.p1;
> +p2 << search.p2;
> +@@
> +
> +msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on line %s
> and return without freeing on line %s" % (p1[0].line,p2[0].line)
> +coccilib.report.print_report(p2[0],msg)
>
> --
> 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

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH] scripts: Coccinelle script for pci_free_consistent()
  2013-04-28 17:04 [PATCH] scripts: Coccinelle script for pci_free_consistent() strnape1
                   ` (6 preceding siblings ...)
  2013-05-02  0:57 ` Julia Lawall
@ 2013-05-02 15:12 ` strnape1
  2013-05-06 20:57 ` Nicolas Palix
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 31+ messages in thread
From: strnape1 @ 2013-05-02 15:12 UTC (permalink / raw)
  To: kernel-janitors

Created coccinelle script for reporting missing pci_free_consistent() calls.

Signed-off-by: Petr Strnad <strnape1@fel.cvut.cz>
---
diff --git a/scripts/coccinelle/free/pci_free_consistent.cocci  
b/scripts/coccinelle/free/pci_free_consistent.cocci
new file mode 100644
index 0000000..3490555
--- /dev/null
+++ b/scripts/coccinelle/free/pci_free_consistent.cocci
@@ -0,0 +1,41 @@
+/// Find missing pci_free_consistent for every pci_alloc_consistent.
+///
+// Confidence: Moderate
+// Copyright: (C) 2013 Petr Strnad.  GPLv2.
+// URL: http://coccinelle.lip6.fr/
+// Keywords: pci_free_consistent, pci_alloc_consistent
+// Options: --no-includes --include-headers
+
+virtual report
+
+@search@
+local idexpression id;
+expression x,y,z;
+statement S1,S2;
+position p1,p2;
+@@
+
+id = pci_alloc_consistent@p1(x,y,&z)
+... when != pci_free_consistent(x,y,id,z)
+    when forall
+(
+if (id = NULL || ...) { ... return ...; }
+|
+if (id) { ... return 0; }
+|
+if (id) S1 else S2 return 0;
+|
+return 0;
+|
+return id;
+|
+*return@p2 ...;
+)
+
+@script:python depends on report@
+p1 << search.p1;
+p2 << search.p2;
+@@
+
+msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on  
line %s and return without freeing on line %s" % (p1[0].line,p2[0].line)
+coccilib.report.print_report(p2[0],msg)




^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [PATCH] scripts: Coccinelle script for pci_free_consistent()
  2013-04-28 17:04 [PATCH] scripts: Coccinelle script for pci_free_consistent() strnape1
                   ` (7 preceding siblings ...)
  2013-05-02 15:12 ` strnape1
@ 2013-05-06 20:57 ` Nicolas Palix
  2013-05-06 21:20 ` strnape1
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 31+ messages in thread
From: Nicolas Palix @ 2013-05-06 20:57 UTC (permalink / raw)
  To: kernel-janitors

Hi,

Could you add the Coccinelle mailing list, the main Linux kernel mailing list
and Michal Marek in copy of your resubmission? So Julia will only have
to Ack your
patch.

BTW thanks for your welcome contribution.

Regards,

On Thu, May 2, 2013 at 2:57 AM, Julia Lawall <julia.lawall@lip6.fr> wrote:
> On Thu, 2 May 2013, strnape1@fel.cvut.cz wrote:
>
>> Created coccinelle script for reporting missing pci_free_consistent() calls.
>>
>> Signed-off-by: Petr Strnad <strnape1@fel.cvut.cz>
>> ---
>> diff --git a/scripts/coccinelle/free/pci_free_consistent.cocci
>> b/scripts/coccinelle/free/pci_free_consistent.cocci
>> new file mode 100644
>> index 0000000..9d9a56f
>> --- /dev/null
>> +++ b/scripts/coccinelle/free/pci_free_consistent.cocci
>> @@ -0,0 +1,44 @@
>> +/// Find missing pci_free_consistent for every pci_alloc_consistent.
>> +///
>> +// Confidence: Moderate
>> +// Copyright: (C) 2013 Petr Strnad.  GPLv2.
>> +// URL: http://coccinelle.lip6.fr/
>> +// Keywords: pci_free_consistent, pci_alloc_consistent
>> +// Options: --no-includes --include-headers
>> +
>> +virtual report
>> +
>> +@search@
>> +local idexpression id;
>> +expression x,y,z;
>> +position p1,p2;
>> +@@
>> +
>> +id = pci_alloc_consistent@p1(x,y,&z)
>> +... when != pci_free_consistent(x,y,id,z)
>> +    when forall
>> +(
>> +if (id = NULL) { ... return ...; }
>> +|
>> +if (id = NULL || (unsigned long)id & 0xFF) { ... return ...; }
>
> The above two lines can be combined into if (id = NULL || ....) { ...
> return ...; }
>
>> +|
>> +if (id = NULL) return ...;
>
> This case shouldn't be necessary.  It should automatically consider { ...
> return ...; } as also matching return ...; (isomorphism).
>
>> +|
>> +if (id) { ... return 0; }
>> +|
>> +if (id) { ... } else { ... } return 0;
>
> Here, I would put S1 and S2, declared as statement metavariables, rather
> than { ... }
>
> julia
>
>> +|
>> +return 0;
>> +|
>> +return id;
>> +|
>> +*return@p2 ...;
>> +)
>> +
>> +@script:python depends on report@
>> +p1 << search.p1;
>> +p2 << search.p2;
>> +@@
>> +
>> +msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on line %s
>> and return without freeing on line %s" % (p1[0].line,p2[0].line)
>> +coccilib.report.print_report(p2[0],msg)
>>
>> --
>> 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
> --
> 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



-- 
Nicolas Palix

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] scripts: Coccinelle script for pci_free_consistent()
  2013-04-28 17:04 [PATCH] scripts: Coccinelle script for pci_free_consistent() strnape1
                   ` (8 preceding siblings ...)
  2013-05-06 20:57 ` Nicolas Palix
@ 2013-05-06 21:20 ` strnape1
  2013-05-07  6:55 ` Dan Carpenter
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 31+ messages in thread
From: strnape1 @ 2013-05-06 21:20 UTC (permalink / raw)
  To: kernel-janitors

Hi,

I would love to, but to be honest Im a bit confused about the mailing  
lists - which one is the main Linux kernel mailing list?  
http://vger.kernel.org/vger-lists.html lists a lot of linux related  
ones and I also cant find any email for Michal Marek (only the  
mmarek@xxxxxxx version). The Coccinelle list is probably  
cocci(at)systeme.lip6.fr, so at least that I did find.
Would appreciate any further info.

With regards, Petr
Quoting Nicolas Palix <nicolas.palix@imag.fr>:

> Hi,
>
> Could you add the Coccinelle mailing list, the main Linux kernel mailing list
> and Michal Marek in copy of your resubmission? So Julia will only have
> to Ack your
> patch.
>
> BTW thanks for your welcome contribution.
>
> Regards,
>
> On Thu, May 2, 2013 at 2:57 AM, Julia Lawall <julia.lawall@lip6.fr> wrote:
>> On Thu, 2 May 2013, strnape1@fel.cvut.cz wrote:
>>
>>> Created coccinelle script for reporting missing  
>>> pci_free_consistent() calls.
>>>
>>> Signed-off-by: Petr Strnad <strnape1@fel.cvut.cz>
>>> ---
>>> diff --git a/scripts/coccinelle/free/pci_free_consistent.cocci
>>> b/scripts/coccinelle/free/pci_free_consistent.cocci
>>> new file mode 100644
>>> index 0000000..9d9a56f
>>> --- /dev/null
>>> +++ b/scripts/coccinelle/free/pci_free_consistent.cocci
>>> @@ -0,0 +1,44 @@
>>> +/// Find missing pci_free_consistent for every pci_alloc_consistent.
>>> +///
>>> +// Confidence: Moderate
>>> +// Copyright: (C) 2013 Petr Strnad.  GPLv2.
>>> +// URL: http://coccinelle.lip6.fr/
>>> +// Keywords: pci_free_consistent, pci_alloc_consistent
>>> +// Options: --no-includes --include-headers
>>> +
>>> +virtual report
>>> +
>>> +@search@
>>> +local idexpression id;
>>> +expression x,y,z;
>>> +position p1,p2;
>>> +@@
>>> +
>>> +id = pci_alloc_consistent@p1(x,y,&z)
>>> +... when != pci_free_consistent(x,y,id,z)
>>> +    when forall
>>> +(
>>> +if (id = NULL) { ... return ...; }
>>> +|
>>> +if (id = NULL || (unsigned long)id & 0xFF) { ... return ...; }
>>
>> The above two lines can be combined into if (id = NULL || ....) { ...
>> return ...; }
>>
>>> +|
>>> +if (id = NULL) return ...;
>>
>> This case shouldn't be necessary.  It should automatically consider { ...
>> return ...; } as also matching return ...; (isomorphism).
>>
>>> +|
>>> +if (id) { ... return 0; }
>>> +|
>>> +if (id) { ... } else { ... } return 0;
>>
>> Here, I would put S1 and S2, declared as statement metavariables, rather
>> than { ... }
>>
>> julia
>>
>>> +|
>>> +return 0;
>>> +|
>>> +return id;
>>> +|
>>> +*return@p2 ...;
>>> +)
>>> +
>>> +@script:python depends on report@
>>> +p1 << search.p1;
>>> +p2 << search.p2;
>>> +@@
>>> +
>>> +msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on line %s
>>> and return without freeing on line %s" % (p1[0].line,p2[0].line)
>>> +coccilib.report.print_report(p2[0],msg)
>>>
>>> --
>>> 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
>> --
>> 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
>
>
>
> --
> Nicolas Palix




^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] scripts: Coccinelle script for pci_free_consistent()
  2013-04-28 17:04 [PATCH] scripts: Coccinelle script for pci_free_consistent() strnape1
                   ` (9 preceding siblings ...)
  2013-05-06 21:20 ` strnape1
@ 2013-05-07  6:55 ` Dan Carpenter
  2013-05-07  6:56 ` Julia Lawall
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 31+ messages in thread
From: Dan Carpenter @ 2013-05-07  6:55 UTC (permalink / raw)
  To: kernel-janitors


On Mon, May 06, 2013 at 11:20:43PM +0200, strnape1@fel.cvut.cz wrote:
> Hi,
> 
> I would love to, but to be honest Im a bit confused about the
> mailing lists - which one is the main Linux kernel mailing list?
> http://vger.kernel.org/vger-lists.html lists a lot of linux related
> ones and I also cant find any email for Michal Marek (only the
> mmarek@xxxxxxx version). The Coccinelle list is probably
> cocci(at)systeme.lip6.fr, so at least that I did find.
> Would appreciate any further info.
> 

It should be that ./scripts/get_maintainer.pl gives you the list
of people to email.  It doesn't work for a new file but you can
run it on the parent directory:

$ ./scripts/get_maintainer.pl -f scripts/coccinelle/free/
Julia Lawall <Julia.Lawall@lip6.fr> (supporter:COCCINELLE/Semant...)
Gilles Muller <Gilles.Muller@lip6.fr> (supporter:COCCINELLE/Semant...)
Nicolas Palix <nicolas.palix@imag.fr> (supporter:COCCINELLE/Semant...)
cocci@systeme.lip6.fr (moderated list:COCCINELLE/Semant...)
linux-kernel@vger.kernel.org (open list)

The kernel mailing list (LKML) is linux-kernel@vger.kernel.org.  The
bad thing is that Michal Marek <mmarek@suse.cz> is not in the list.
He should be added to the COCCINELLE section in the MAINTAINERS
file.

Btw, my normal rule for sending patches is that I only CC lkml if
there isn't another mailing list.  Everyone who cares about
coccinelle scripts is on the cocci@systeme.lip6.fr email list.  If
you email LKML then Andrew Morton will read it but literally no one
else reads the patches from LKML.

I always CC one public development mailing list so if there is
nothing else I do CC lkml.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] scripts: Coccinelle script for pci_free_consistent()
  2013-04-28 17:04 [PATCH] scripts: Coccinelle script for pci_free_consistent() strnape1
                   ` (10 preceding siblings ...)
  2013-05-07  6:55 ` Dan Carpenter
@ 2013-05-07  6:56 ` Julia Lawall
  2013-05-08 12:20 ` strnape1
                   ` (3 subsequent siblings)
  15 siblings, 0 replies; 31+ messages in thread
From: Julia Lawall @ 2013-05-07  6:56 UTC (permalink / raw)
  To: kernel-janitors

On Mon, 6 May 2013, strnape1@fel.cvut.cz wrote:

> Hi,
>
> I would love to, but to be honest Im a bit confused about the mailing lists -
> which one is the main Linux kernel mailing list?
> http://vger.kernel.org/vger-lists.html lists a lot of linux related ones and I
> also cant find any email for Michal Marek (only the mmarek@xxxxxxx version).

Michal Marek <mmarek@suse.cz>

But I had another proposition for improving the semantic patch.  I will
send it this evening.

julia

> The Coccinelle list is probably cocci(at)systeme.lip6.fr, so at least that I
> did find.
> Would appreciate any further info.
>
> With regards, Petr
> Quoting Nicolas Palix <nicolas.palix@imag.fr>:
>
> > Hi,
> >
> > Could you add the Coccinelle mailing list, the main Linux kernel mailing
> > list
> > and Michal Marek in copy of your resubmission? So Julia will only have
> > to Ack your
> > patch.
> >
> > BTW thanks for your welcome contribution.
> >
> > Regards,
> >
> > On Thu, May 2, 2013 at 2:57 AM, Julia Lawall <julia.lawall@lip6.fr> wrote:
> > > On Thu, 2 May 2013, strnape1@fel.cvut.cz wrote:
> > >
> > > > Created coccinelle script for reporting missing pci_free_consistent()
> > > > calls.
> > > >
> > > > Signed-off-by: Petr Strnad <strnape1@fel.cvut.cz>
> > > > ---
> > > > diff --git a/scripts/coccinelle/free/pci_free_consistent.cocci
> > > > b/scripts/coccinelle/free/pci_free_consistent.cocci
> > > > new file mode 100644
> > > > index 0000000..9d9a56f
> > > > --- /dev/null
> > > > +++ b/scripts/coccinelle/free/pci_free_consistent.cocci
> > > > @@ -0,0 +1,44 @@
> > > > +/// Find missing pci_free_consistent for every pci_alloc_consistent.
> > > > +///
> > > > +// Confidence: Moderate
> > > > +// Copyright: (C) 2013 Petr Strnad.  GPLv2.
> > > > +// URL: http://coccinelle.lip6.fr/
> > > > +// Keywords: pci_free_consistent, pci_alloc_consistent
> > > > +// Options: --no-includes --include-headers
> > > > +
> > > > +virtual report
> > > > +
> > > > +@search@
> > > > +local idexpression id;
> > > > +expression x,y,z;
> > > > +position p1,p2;
> > > > +@@
> > > > +
> > > > +id = pci_alloc_consistent@p1(x,y,&z)
> > > > +... when != pci_free_consistent(x,y,id,z)
> > > > +    when forall
> > > > +(
> > > > +if (id = NULL) { ... return ...; }
> > > > +|
> > > > +if (id = NULL || (unsigned long)id & 0xFF) { ... return ...; }
> > >
> > > The above two lines can be combined into if (id = NULL || ....) { ...
> > > return ...; }
> > >
> > > > +|
> > > > +if (id = NULL) return ...;
> > >
> > > This case shouldn't be necessary.  It should automatically consider { ...
> > > return ...; } as also matching return ...; (isomorphism).
> > >
> > > > +|
> > > > +if (id) { ... return 0; }
> > > > +|
> > > > +if (id) { ... } else { ... } return 0;
> > >
> > > Here, I would put S1 and S2, declared as statement metavariables, rather
> > > than { ... }
> > >
> > > julia
> > >
> > > > +|
> > > > +return 0;
> > > > +|
> > > > +return id;
> > > > +|
> > > > +*return@p2 ...;
> > > > +)
> > > > +
> > > > +@script:python depends on report@
> > > > +p1 << search.p1;
> > > > +p2 << search.p2;
> > > > +@@
> > > > +
> > > > +msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on line
> > > > %s
> > > > and return without freeing on line %s" % (p1[0].line,p2[0].line)
> > > > +coccilib.report.print_report(p2[0],msg)
> > > >
> > > > --
> > > > 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
> > > --
> > > 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
> >
> >
> >
> > --
> > Nicolas Palix
>
>
>

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] scripts: Coccinelle script for pci_free_consistent()
  2013-04-28 17:04 [PATCH] scripts: Coccinelle script for pci_free_consistent() strnape1
                   ` (11 preceding siblings ...)
  2013-05-07  6:56 ` Julia Lawall
@ 2013-05-08 12:20 ` strnape1
  2013-05-08 14:49 ` Julia Lawall
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 31+ messages in thread
From: strnape1 @ 2013-05-08 12:20 UTC (permalink / raw)
  To: kernel-janitors

So, what is the proposition for improving the patch?
Quoting Julia Lawall <julia.lawall@lip6.fr>:

> On Mon, 6 May 2013, strnape1@fel.cvut.cz wrote:
>
>> Hi,
>>
>> I would love to, but to be honest Im a bit confused about the  
>> mailing lists -
>> which one is the main Linux kernel mailing list?
>> http://vger.kernel.org/vger-lists.html lists a lot of linux related  
>> ones and I
>> also cant find any email for Michal Marek (only the mmarek@xxxxxxx version).
>
> Michal Marek <mmarek@suse.cz>
>
> But I had another proposition for improving the semantic patch.  I will
> send it this evening.
>
> julia
>
>> The Coccinelle list is probably cocci(at)systeme.lip6.fr, so at least that I
>> did find.
>> Would appreciate any further info.
>>
>> With regards, Petr
>> Quoting Nicolas Palix <nicolas.palix@imag.fr>:
>>
>> > Hi,
>> >
>> > Could you add the Coccinelle mailing list, the main Linux kernel mailing
>> > list
>> > and Michal Marek in copy of your resubmission? So Julia will only have
>> > to Ack your
>> > patch.
>> >
>> > BTW thanks for your welcome contribution.
>> >
>> > Regards,
>> >
>> > On Thu, May 2, 2013 at 2:57 AM, Julia Lawall <julia.lawall@lip6.fr> wrote:
>> > > On Thu, 2 May 2013, strnape1@fel.cvut.cz wrote:
>> > >
>> > > > Created coccinelle script for reporting missing pci_free_consistent()
>> > > > calls.
>> > > >
>> > > > Signed-off-by: Petr Strnad <strnape1@fel.cvut.cz>
>> > > > ---
>> > > > diff --git a/scripts/coccinelle/free/pci_free_consistent.cocci
>> > > > b/scripts/coccinelle/free/pci_free_consistent.cocci
>> > > > new file mode 100644
>> > > > index 0000000..9d9a56f
>> > > > --- /dev/null
>> > > > +++ b/scripts/coccinelle/free/pci_free_consistent.cocci
>> > > > @@ -0,0 +1,44 @@
>> > > > +/// Find missing pci_free_consistent for every pci_alloc_consistent.
>> > > > +///
>> > > > +// Confidence: Moderate
>> > > > +// Copyright: (C) 2013 Petr Strnad.  GPLv2.
>> > > > +// URL: http://coccinelle.lip6.fr/
>> > > > +// Keywords: pci_free_consistent, pci_alloc_consistent
>> > > > +// Options: --no-includes --include-headers
>> > > > +
>> > > > +virtual report
>> > > > +
>> > > > +@search@
>> > > > +local idexpression id;
>> > > > +expression x,y,z;
>> > > > +position p1,p2;
>> > > > +@@
>> > > > +
>> > > > +id = pci_alloc_consistent@p1(x,y,&z)
>> > > > +... when != pci_free_consistent(x,y,id,z)
>> > > > +    when forall
>> > > > +(
>> > > > +if (id = NULL) { ... return ...; }
>> > > > +|
>> > > > +if (id = NULL || (unsigned long)id & 0xFF) { ... return ...; }
>> > >
>> > > The above two lines can be combined into if (id = NULL || ....) { ...
>> > > return ...; }
>> > >
>> > > > +|
>> > > > +if (id = NULL) return ...;
>> > >
>> > > This case shouldn't be necessary.  It should automatically  
>> consider { ...
>> > > return ...; } as also matching return ...; (isomorphism).
>> > >
>> > > > +|
>> > > > +if (id) { ... return 0; }
>> > > > +|
>> > > > +if (id) { ... } else { ... } return 0;
>> > >
>> > > Here, I would put S1 and S2, declared as statement metavariables, rather
>> > > than { ... }
>> > >
>> > > julia
>> > >
>> > > > +|
>> > > > +return 0;
>> > > > +|
>> > > > +return id;
>> > > > +|
>> > > > +*return@p2 ...;
>> > > > +)
>> > > > +
>> > > > +@script:python depends on report@
>> > > > +p1 << search.p1;
>> > > > +p2 << search.p2;
>> > > > +@@
>> > > > +
>> > > > +msg = "ERROR: missing pci_free_consistent;  
>> pci_alloc_consistent on line
>> > > > %s
>> > > > and return without freeing on line %s" % (p1[0].line,p2[0].line)
>> > > > +coccilib.report.print_report(p2[0],msg)
>> > > >
>> > > > --
>> > > > 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
>> > > --
>> > > 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
>> >
>> >
>> >
>> > --
>> > Nicolas Palix
>>
>>
>>




^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] scripts: Coccinelle script for pci_free_consistent()
  2013-04-28 17:04 [PATCH] scripts: Coccinelle script for pci_free_consistent() strnape1
                   ` (12 preceding siblings ...)
  2013-05-08 12:20 ` strnape1
@ 2013-05-08 14:49 ` Julia Lawall
  2013-05-08 15:46 ` strnape1
  2013-05-08 15:52 ` Julia Lawall
  15 siblings, 0 replies; 31+ messages in thread
From: Julia Lawall @ 2013-05-08 14:49 UTC (permalink / raw)
  To: kernel-janitors

Here is a proposal.  Some features:

* It assumes that the result of pci_alloc_consistent is null tested, and
doesn't report any problems before that.

* It uses exists rather than forall, to find a bug when there is a problem
on just one execution path.

* It gives no warning if the return value is stored elsewhere or is freed
under some kinds of if.

* It recognizes 1 as a success value.

On linux-next, this gives 10 reports.  At least half of them are false
positives, mostly due to interprocedural effects, which this rule does not
at all take into account.

julia

/// Find missing pci_free_consistent for every pci_alloc_consistent.
///
// Confidence: Moderate
// Copyright: (C) 2013 Petr Strnad.  GPLv2.
// URL: http://coccinelle.lip6.fr/
// Keywords: pci_free_consistent, pci_alloc_consistent
// Options: --no-includes --include-headers

virtual report
virtual org

@search@
local idexpression id;
expression x,y,z,e;
position p1,p2;
type T;
@@

id = pci_alloc_consistent@p1(x,y,&z)
... when != e = id
if (id = NULL || ...) { ... return ...; }
... when != pci_free_consistent(x,y,id,z)
    when != if (id) { ... pci_free_consistent(x,y,id,z) ... }
    when != if (y) { ... pci_free_consistent(x,y,id,z) ... }
    when != e = (T)id
    when exists
(
return 0;
|
return 1;
|
return id;
|
return@p2 ...;
)

@script:python depends on report@
p1 << search.p1;
p2 << search.p2;
@@

msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on line %s and return without freeing on line %s" % (p1[0].line,p2[0].line)
coccilib.report.print_report(p2[0],msg)

@script:python depends on org@
p1 << search.p1;
p2 << search.p2;
@@

msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on line %s and return without freeing on line %s" % (p1[0].line,p2[0].line)
cocci.print_main(msg,p1)
cocci.print_secs("",p2)


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] scripts: Coccinelle script for pci_free_consistent()
  2013-04-28 17:04 [PATCH] scripts: Coccinelle script for pci_free_consistent() strnape1
                   ` (13 preceding siblings ...)
  2013-05-08 14:49 ` Julia Lawall
@ 2013-05-08 15:46 ` strnape1
  2013-05-08 15:52 ` Julia Lawall
  15 siblings, 0 replies; 31+ messages in thread
From: strnape1 @ 2013-05-08 15:46 UTC (permalink / raw)
  To: kernel-janitors

Alright, so should I make a patch from it?
Quoting Julia Lawall <julia.lawall@lip6.fr>:

> Here is a proposal.  Some features:
>
> * It assumes that the result of pci_alloc_consistent is null tested, and
> doesn't report any problems before that.
>
> * It uses exists rather than forall, to find a bug when there is a problem
> on just one execution path.
>
> * It gives no warning if the return value is stored elsewhere or is freed
> under some kinds of if.
>
> * It recognizes 1 as a success value.
>
> On linux-next, this gives 10 reports.  At least half of them are false
> positives, mostly due to interprocedural effects, which this rule does not
> at all take into account.
>
> julia
>
> /// Find missing pci_free_consistent for every pci_alloc_consistent.
> ///
> // Confidence: Moderate
> // Copyright: (C) 2013 Petr Strnad.  GPLv2.
> // URL: http://coccinelle.lip6.fr/
> // Keywords: pci_free_consistent, pci_alloc_consistent
> // Options: --no-includes --include-headers
>
> virtual report
> virtual org
>
> @search@
> local idexpression id;
> expression x,y,z,e;
> position p1,p2;
> type T;
> @@
>
> id = pci_alloc_consistent@p1(x,y,&z)
> ... when != e = id
> if (id = NULL || ...) { ... return ...; }
> ... when != pci_free_consistent(x,y,id,z)
>     when != if (id) { ... pci_free_consistent(x,y,id,z) ... }
>     when != if (y) { ... pci_free_consistent(x,y,id,z) ... }
>     when != e = (T)id
>     when exists
> (
> return 0;
> |
> return 1;
> |
> return id;
> |
> return@p2 ...;
> )
>
> @script:python depends on report@
> p1 << search.p1;
> p2 << search.p2;
> @@
>
> msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on  
> line %s and return without freeing on line %s" %  
> (p1[0].line,p2[0].line)
> coccilib.report.print_report(p2[0],msg)
>
> @script:python depends on org@
> p1 << search.p1;
> p2 << search.p2;
> @@
>
> msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on  
> line %s and return without freeing on line %s" %  
> (p1[0].line,p2[0].line)
> cocci.print_main(msg,p1)
> cocci.print_secs("",p2)




^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] scripts: Coccinelle script for pci_free_consistent()
  2013-04-28 17:04 [PATCH] scripts: Coccinelle script for pci_free_consistent() strnape1
                   ` (14 preceding siblings ...)
  2013-05-08 15:46 ` strnape1
@ 2013-05-08 15:52 ` Julia Lawall
  15 siblings, 0 replies; 31+ messages in thread
From: Julia Lawall @ 2013-05-08 15:52 UTC (permalink / raw)
  To: kernel-janitors

On Wed, 8 May 2013, strnape1@fel.cvut.cz wrote:

> Alright, so should I make a patch from it?

Could you check that it does what you expect?  If everything is OK, then
you can make a patch.

thanks,
julia

> Quoting Julia Lawall <julia.lawall@lip6.fr>:
>
> > Here is a proposal.  Some features:
> >
> > * It assumes that the result of pci_alloc_consistent is null tested, and
> > doesn't report any problems before that.
> >
> > * It uses exists rather than forall, to find a bug when there is a problem
> > on just one execution path.
> >
> > * It gives no warning if the return value is stored elsewhere or is freed
> > under some kinds of if.
> >
> > * It recognizes 1 as a success value.
> >
> > On linux-next, this gives 10 reports.  At least half of them are false
> > positives, mostly due to interprocedural effects, which this rule does not
> > at all take into account.
> >
> > julia
> >
> > /// Find missing pci_free_consistent for every pci_alloc_consistent.
> > ///
> > // Confidence: Moderate
> > // Copyright: (C) 2013 Petr Strnad.  GPLv2.
> > // URL: http://coccinelle.lip6.fr/
> > // Keywords: pci_free_consistent, pci_alloc_consistent
> > // Options: --no-includes --include-headers
> >
> > virtual report
> > virtual org
> >
> > @search@
> > local idexpression id;
> > expression x,y,z,e;
> > position p1,p2;
> > type T;
> > @@
> >
> > id = pci_alloc_consistent@p1(x,y,&z)
> > ... when != e = id
> > if (id = NULL || ...) { ... return ...; }
> > ... when != pci_free_consistent(x,y,id,z)
> >    when != if (id) { ... pci_free_consistent(x,y,id,z) ... }
> >    when != if (y) { ... pci_free_consistent(x,y,id,z) ... }
> >    when != e = (T)id
> >    when exists
> > (
> > return 0;
> > |
> > return 1;
> > |
> > return id;
> > |
> > return@p2 ...;
> > )
> >
> > @script:python depends on report@
> > p1 << search.p1;
> > p2 << search.p2;
> > @@
> >
> > msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on line %s
> > and return without freeing on line %s" % (p1[0].line,p2[0].line)
> > coccilib.report.print_report(p2[0],msg)
> >
> > @script:python depends on org@
> > p1 << search.p1;
> > p2 << search.p2;
> > @@
> >
> > msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on line %s
> > and return without freeing on line %s" % (p1[0].line,p2[0].line)
> > cocci.print_main(msg,p1)
> > cocci.print_secs("",p2)
>
>
>
> --
> 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

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH] scripts: Coccinelle script for pci_free_consistent()
  2013-04-28 17:04 [PATCH] scripts: Coccinelle script for pci_free_consistent() strnape1
  2013-04-28 23:05 ` Julia Lawall
@ 2013-05-08 16:28 ` strnape1
  2013-04-29 23:35 ` Julia Lawall
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 31+ messages in thread
From: strnape1 @ 2013-05-08 16:28 UTC (permalink / raw)
  To: kernel-janitors; +Cc: linux-kernel, cocci, mmarek, julia.lawall

Created coccinelle script for reporting missing pci_free_consistent() calls.

Signed-off-by: Petr Strnad <strnape1@fel.cvut.cz>
---
/// Find missing pci_free_consistent for every pci_alloc_consistent.
///
// Confidence: Moderate
// Copyright: (C) 2013 Petr Strnad.  GPLv2.
// URL: http://coccinelle.lip6.fr/
// Keywords: pci_free_consistent, pci_alloc_consistent
// Options: --no-includes --include-headers

virtual report
virtual org

@search@
local idexpression id;
expression x,y,z,e;
position p1,p2;
type T;
@@

id = pci_alloc_consistent@p1(x,y,&z)
... when != e = id
if (id == NULL || ...) { ... return ...; }
... when != pci_free_consistent(x,y,id,z)
     when != if (id) { ... pci_free_consistent(x,y,id,z) ... }
     when != if (y) { ... pci_free_consistent(x,y,id,z) ... }
     when != e = (T)id
     when exists
(
return 0;
|
return 1;
|
return id;
|
return@p2 ...;
)

@script:python depends on report@
p1 << search.p1;
p2 << search.p2;
@@

msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on  
line %s and return without freeing on line %s" % (p1[0].line,p2[0].line)
coccilib.report.print_report(p2[0],msg)

@script:python depends on org@
p1 << search.p1;
p2 << search.p2;
@@

msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on  
line %s and return without freeing on line %s" % (p1[0].line,p2[0].line)
cocci.print_main(msg,p1)
cocci.print_secs("",p2)


^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH] scripts: Coccinelle script for pci_free_consistent()
@ 2013-05-08 16:28 ` strnape1
  0 siblings, 0 replies; 31+ messages in thread
From: strnape1 @ 2013-05-08 16:28 UTC (permalink / raw)
  To: cocci

Created coccinelle script for reporting missing pci_free_consistent() calls.

Signed-off-by: Petr Strnad <strnape1@fel.cvut.cz>
---
/// Find missing pci_free_consistent for every pci_alloc_consistent.
///
// Confidence: Moderate
// Copyright: (C) 2013 Petr Strnad.  GPLv2.
// URL: http://coccinelle.lip6.fr/
// Keywords: pci_free_consistent, pci_alloc_consistent
// Options: --no-includes --include-headers

virtual report
virtual org

@search@
local idexpression id;
expression x,y,z,e;
position p1,p2;
type T;
@@

id = pci_alloc_consistent@p1(x,y,&z)
... when != e = id
if (id = NULL || ...) { ... return ...; }
... when != pci_free_consistent(x,y,id,z)
     when != if (id) { ... pci_free_consistent(x,y,id,z) ... }
     when != if (y) { ... pci_free_consistent(x,y,id,z) ... }
     when != e = (T)id
     when exists
(
return 0;
|
return 1;
|
return id;
|
return@p2 ...;
)

@script:python depends on report@
p1 << search.p1;
p2 << search.p2;
@@

msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on  
line %s and return without freeing on line %s" % (p1[0].line,p2[0].line)
coccilib.report.print_report(p2[0],msg)

@script:python depends on org@
p1 << search.p1;
p2 << search.p2;
@@

msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on  
line %s and return without freeing on line %s" % (p1[0].line,p2[0].line)
cocci.print_main(msg,p1)
cocci.print_secs("",p2)


^ permalink raw reply	[flat|nested] 31+ messages in thread

* [Cocci] [PATCH] scripts: Coccinelle script for pci_free_consistent()
@ 2013-05-08 16:28 ` strnape1
  0 siblings, 0 replies; 31+ messages in thread
From: strnape1 at fel.cvut.cz @ 2013-05-08 16:28 UTC (permalink / raw)
  To: cocci

Created coccinelle script for reporting missing pci_free_consistent() calls.

Signed-off-by: Petr Strnad <strnape1@fel.cvut.cz>
---
/// Find missing pci_free_consistent for every pci_alloc_consistent.
///
// Confidence: Moderate
// Copyright: (C) 2013 Petr Strnad.  GPLv2.
// URL: http://coccinelle.lip6.fr/
// Keywords: pci_free_consistent, pci_alloc_consistent
// Options: --no-includes --include-headers

virtual report
virtual org

@search@
local idexpression id;
expression x,y,z,e;
position p1,p2;
type T;
@@

id = pci_alloc_consistent at p1(x,y,&z)
... when != e = id
if (id == NULL || ...) { ... return ...; }
... when != pci_free_consistent(x,y,id,z)
     when != if (id) { ... pci_free_consistent(x,y,id,z) ... }
     when != if (y) { ... pci_free_consistent(x,y,id,z) ... }
     when != e = (T)id
     when exists
(
return 0;
|
return 1;
|
return id;
|
return at p2 ...;
)

@script:python depends on report@
p1 << search.p1;
p2 << search.p2;
@@

msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on  
line %s and return without freeing on line %s" % (p1[0].line,p2[0].line)
coccilib.report.print_report(p2[0],msg)

@script:python depends on org@
p1 << search.p1;
p2 << search.p2;
@@

msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on  
line %s and return without freeing on line %s" % (p1[0].line,p2[0].line)
cocci.print_main(msg,p1)
cocci.print_secs("",p2)

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH] scripts: Coccinelle script for pci_free_consistent()
  2013-04-28 17:04 [PATCH] scripts: Coccinelle script for pci_free_consistent() strnape1
@ 2013-05-08 21:03 ` strnape1
  2013-04-29 21:06 ` strnape1
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 31+ messages in thread
From: strnape1 @ 2013-05-08 21:03 UTC (permalink / raw)
  To: kernel-janitors; +Cc: linux-kernel, cocci, mmarek, julia.lawall

Created coccinelle script for reporting missing pci_free_consistent() calls.

Signed-off-by: Petr Strnad <strnape1@fel.cvut.cz>
---
diff --git a/scripts/coccinelle/free/pci_free_consistent.cocci  
b/scripts/coccinelle/free/pci_free_consistent.cocci
new file mode 100644
index 0000000..43600cc
--- /dev/null
+++ b/scripts/coccinelle/free/pci_free_consistent.cocci
@@ -0,0 +1,52 @@
+/// Find missing pci_free_consistent for every pci_alloc_consistent.
+///
+// Confidence: Moderate
+// Copyright: (C) 2013 Petr Strnad.  GPLv2.
+// URL: http://coccinelle.lip6.fr/
+// Keywords: pci_free_consistent, pci_alloc_consistent
+// Options: --no-includes --include-headers
+
+virtual report
+virtual org
+
+@search@
+local idexpression id;
+expression x,y,z,e;
+position p1,p2;
+type T;
+@@
+
+id = pci_alloc_consistent@p1(x,y,&z)
+... when != e = id
+if (id == NULL || ...) { ... return ...; }
+... when != pci_free_consistent(x,y,id,z)
+    when != if (id) { ... pci_free_consistent(x,y,id,z) ... }
+    when != if (y) { ... pci_free_consistent(x,y,id,z) ... }
+    when != e = (T)id
+    when exists
+(
+return 0;
+|
+return 1;
+|
+return id;
+|
+return@p2 ...;
+)
+
+@script:python depends on report@
+p1 << search.p1;
+p2 << search.p2;
+@@
+
+msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on  
line %s and return without freeing on line %s" % (p1[0].line,p2[0].line)
+coccilib.report.print_report(p2[0],msg)
+
+@script:python depends on org@
+p1 << search.p1;
+p2 << search.p2;
+@@
+
+msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on  
line %s and return without freeing on line %s" % (p1[0].line,p2[0].line)
+cocci.print_main(msg,p1)
+cocci.print_secs("",p2)


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH] scripts: Coccinelle script for pci_free_consistent()
@ 2013-05-08 21:03 ` strnape1
  0 siblings, 0 replies; 31+ messages in thread
From: strnape1 @ 2013-05-08 21:03 UTC (permalink / raw)
  To: kernel-janitors; +Cc: linux-kernel, cocci, mmarek, julia.lawall

Created coccinelle script for reporting missing pci_free_consistent() calls.

Signed-off-by: Petr Strnad <strnape1@fel.cvut.cz>
---
diff --git a/scripts/coccinelle/free/pci_free_consistent.cocci  
b/scripts/coccinelle/free/pci_free_consistent.cocci
new file mode 100644
index 0000000..43600cc
--- /dev/null
+++ b/scripts/coccinelle/free/pci_free_consistent.cocci
@@ -0,0 +1,52 @@
+/// Find missing pci_free_consistent for every pci_alloc_consistent.
+///
+// Confidence: Moderate
+// Copyright: (C) 2013 Petr Strnad.  GPLv2.
+// URL: http://coccinelle.lip6.fr/
+// Keywords: pci_free_consistent, pci_alloc_consistent
+// Options: --no-includes --include-headers
+
+virtual report
+virtual org
+
+@search@
+local idexpression id;
+expression x,y,z,e;
+position p1,p2;
+type T;
+@@
+
+id = pci_alloc_consistent@p1(x,y,&z)
+... when != e = id
+if (id = NULL || ...) { ... return ...; }
+... when != pci_free_consistent(x,y,id,z)
+    when != if (id) { ... pci_free_consistent(x,y,id,z) ... }
+    when != if (y) { ... pci_free_consistent(x,y,id,z) ... }
+    when != e = (T)id
+    when exists
+(
+return 0;
+|
+return 1;
+|
+return id;
+|
+return@p2 ...;
+)
+
+@script:python depends on report@
+p1 << search.p1;
+p2 << search.p2;
+@@
+
+msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on  
line %s and return without freeing on line %s" % (p1[0].line,p2[0].line)
+coccilib.report.print_report(p2[0],msg)
+
+@script:python depends on org@
+p1 << search.p1;
+p2 << search.p2;
+@@
+
+msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on  
line %s and return without freeing on line %s" % (p1[0].line,p2[0].line)
+cocci.print_main(msg,p1)
+cocci.print_secs("",p2)


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [PATCH] scripts: Coccinelle script for pci_free_consistent()
  2013-05-08 21:03 ` strnape1
  (?)
@ 2013-06-14 13:25   ` Michal Marek
  -1 siblings, 0 replies; 31+ messages in thread
From: Michal Marek @ 2013-06-14 13:25 UTC (permalink / raw)
  To: strnape1
  Cc: kernel-janitors, linux-kernel, cocci, julia.lawall, Nicolas Palix

On 8.5.2013 23:03, strnape1@fel.cvut.cz wrote:
> Created coccinelle script for reporting missing pci_free_consistent() calls.
> 
> Signed-off-by: Petr Strnad <strnape1@fel.cvut.cz>

Julia, Nicolas, any comments about this patch?

Thanks,
Michal

> ---
> diff --git a/scripts/coccinelle/free/pci_free_consistent.cocci  
> b/scripts/coccinelle/free/pci_free_consistent.cocci
> new file mode 100644
> index 0000000..43600cc
> --- /dev/null
> +++ b/scripts/coccinelle/free/pci_free_consistent.cocci
> @@ -0,0 +1,52 @@
> +/// Find missing pci_free_consistent for every pci_alloc_consistent.
> +///
> +// Confidence: Moderate
> +// Copyright: (C) 2013 Petr Strnad.  GPLv2.
> +// URL: http://coccinelle.lip6.fr/
> +// Keywords: pci_free_consistent, pci_alloc_consistent
> +// Options: --no-includes --include-headers
> +
> +virtual report
> +virtual org
> +
> +@search@
> +local idexpression id;
> +expression x,y,z,e;
> +position p1,p2;
> +type T;
> +@@
> +
> +id = pci_alloc_consistent@p1(x,y,&z)
> +... when != e = id
> +if (id == NULL || ...) { ... return ...; }
> +... when != pci_free_consistent(x,y,id,z)
> +    when != if (id) { ... pci_free_consistent(x,y,id,z) ... }
> +    when != if (y) { ... pci_free_consistent(x,y,id,z) ... }
> +    when != e = (T)id
> +    when exists
> +(
> +return 0;
> +|
> +return 1;
> +|
> +return id;
> +|
> +return@p2 ...;
> +)
> +
> +@script:python depends on report@
> +p1 << search.p1;
> +p2 << search.p2;
> +@@
> +
> +msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on  
> line %s and return without freeing on line %s" % (p1[0].line,p2[0].line)
> +coccilib.report.print_report(p2[0],msg)
> +
> +@script:python depends on org@
> +p1 << search.p1;
> +p2 << search.p2;
> +@@
> +
> +msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on  
> line %s and return without freeing on line %s" % (p1[0].line,p2[0].line)
> +cocci.print_main(msg,p1)
> +cocci.print_secs("",p2)
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 



^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] scripts: Coccinelle script for pci_free_consistent()
@ 2013-06-14 13:25   ` Michal Marek
  0 siblings, 0 replies; 31+ messages in thread
From: Michal Marek @ 2013-06-14 13:25 UTC (permalink / raw)
  To: cocci

On 8.5.2013 23:03, strnape1@fel.cvut.cz wrote:
> Created coccinelle script for reporting missing pci_free_consistent() calls.
> 
> Signed-off-by: Petr Strnad <strnape1@fel.cvut.cz>

Julia, Nicolas, any comments about this patch?

Thanks,
Michal

> ---
> diff --git a/scripts/coccinelle/free/pci_free_consistent.cocci  
> b/scripts/coccinelle/free/pci_free_consistent.cocci
> new file mode 100644
> index 0000000..43600cc
> --- /dev/null
> +++ b/scripts/coccinelle/free/pci_free_consistent.cocci
> @@ -0,0 +1,52 @@
> +/// Find missing pci_free_consistent for every pci_alloc_consistent.
> +///
> +// Confidence: Moderate
> +// Copyright: (C) 2013 Petr Strnad.  GPLv2.
> +// URL: http://coccinelle.lip6.fr/
> +// Keywords: pci_free_consistent, pci_alloc_consistent
> +// Options: --no-includes --include-headers
> +
> +virtual report
> +virtual org
> +
> +@search@
> +local idexpression id;
> +expression x,y,z,e;
> +position p1,p2;
> +type T;
> +@@
> +
> +id = pci_alloc_consistent@p1(x,y,&z)
> +... when != e = id
> +if (id = NULL || ...) { ... return ...; }
> +... when != pci_free_consistent(x,y,id,z)
> +    when != if (id) { ... pci_free_consistent(x,y,id,z) ... }
> +    when != if (y) { ... pci_free_consistent(x,y,id,z) ... }
> +    when != e = (T)id
> +    when exists
> +(
> +return 0;
> +|
> +return 1;
> +|
> +return id;
> +|
> +return@p2 ...;
> +)
> +
> +@script:python depends on report@
> +p1 << search.p1;
> +p2 << search.p2;
> +@@
> +
> +msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on  
> line %s and return without freeing on line %s" % (p1[0].line,p2[0].line)
> +coccilib.report.print_report(p2[0],msg)
> +
> +@script:python depends on org@
> +p1 << search.p1;
> +p2 << search.p2;
> +@@
> +
> +msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on  
> line %s and return without freeing on line %s" % (p1[0].line,p2[0].line)
> +cocci.print_main(msg,p1)
> +cocci.print_secs("",p2)
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 



^ permalink raw reply	[flat|nested] 31+ messages in thread

* [Cocci] [PATCH] scripts: Coccinelle script for pci_free_consistent()
@ 2013-06-14 13:25   ` Michal Marek
  0 siblings, 0 replies; 31+ messages in thread
From: Michal Marek @ 2013-06-14 13:25 UTC (permalink / raw)
  To: cocci

On 8.5.2013 23:03, strnape1 at fel.cvut.cz wrote:
> Created coccinelle script for reporting missing pci_free_consistent() calls.
> 
> Signed-off-by: Petr Strnad <strnape1@fel.cvut.cz>

Julia, Nicolas, any comments about this patch?

Thanks,
Michal

> ---
> diff --git a/scripts/coccinelle/free/pci_free_consistent.cocci  
> b/scripts/coccinelle/free/pci_free_consistent.cocci
> new file mode 100644
> index 0000000..43600cc
> --- /dev/null
> +++ b/scripts/coccinelle/free/pci_free_consistent.cocci
> @@ -0,0 +1,52 @@
> +/// Find missing pci_free_consistent for every pci_alloc_consistent.
> +///
> +// Confidence: Moderate
> +// Copyright: (C) 2013 Petr Strnad.  GPLv2.
> +// URL: http://coccinelle.lip6.fr/
> +// Keywords: pci_free_consistent, pci_alloc_consistent
> +// Options: --no-includes --include-headers
> +
> +virtual report
> +virtual org
> +
> + at search@
> +local idexpression id;
> +expression x,y,z,e;
> +position p1,p2;
> +type T;
> +@@
> +
> +id = pci_alloc_consistent at p1(x,y,&z)
> +... when != e = id
> +if (id == NULL || ...) { ... return ...; }
> +... when != pci_free_consistent(x,y,id,z)
> +    when != if (id) { ... pci_free_consistent(x,y,id,z) ... }
> +    when != if (y) { ... pci_free_consistent(x,y,id,z) ... }
> +    when != e = (T)id
> +    when exists
> +(
> +return 0;
> +|
> +return 1;
> +|
> +return id;
> +|
> +return at p2 ...;
> +)
> +
> + at script:python depends on report@
> +p1 << search.p1;
> +p2 << search.p2;
> +@@
> +
> +msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on  
> line %s and return without freeing on line %s" % (p1[0].line,p2[0].line)
> +coccilib.report.print_report(p2[0],msg)
> +
> + at script:python depends on org@
> +p1 << search.p1;
> +p2 << search.p2;
> +@@
> +
> +msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on  
> line %s and return without freeing on line %s" % (p1[0].line,p2[0].line)
> +cocci.print_main(msg,p1)
> +cocci.print_secs("",p2)
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] scripts: Coccinelle script for pci_free_consistent()
  2013-05-08 21:03 ` strnape1
  (?)
@ 2013-06-25 13:03   ` Nicolas Palix
  -1 siblings, 0 replies; 31+ messages in thread
From: Nicolas Palix @ 2013-06-25 13:03 UTC (permalink / raw)
  To: strnape1; +Cc: kernel-janitors, LKML, Coccinelle, Michal Marek, Julia Lawall

On Wed, May 8, 2013 at 11:03 PM,  <strnape1@fel.cvut.cz> wrote:
> Created coccinelle script for reporting missing pci_free_consistent() calls.
>
> Signed-off-by: Petr Strnad <strnape1@fel.cvut.cz>

Signed-off-by: Nicolas Palix <nicolas.palix@imag.fr>

> ---
> diff --git a/scripts/coccinelle/free/pci_free_consistent.cocci
> b/scripts/coccinelle/free/pci_free_consistent.cocci
> new file mode 100644
> index 0000000..43600cc
> --- /dev/null
> +++ b/scripts/coccinelle/free/pci_free_consistent.cocci
> @@ -0,0 +1,52 @@
> +/// Find missing pci_free_consistent for every pci_alloc_consistent.
> +///
> +// Confidence: Moderate
> +// Copyright: (C) 2013 Petr Strnad.  GPLv2.
> +// URL: http://coccinelle.lip6.fr/
> +// Keywords: pci_free_consistent, pci_alloc_consistent
> +// Options: --no-includes --include-headers
> +
> +virtual report
> +virtual org
> +
> +@search@
> +local idexpression id;
> +expression x,y,z,e;
> +position p1,p2;
> +type T;
> +@@
> +
> +id = pci_alloc_consistent@p1(x,y,&z)
> +... when != e = id
> +if (id == NULL || ...) { ... return ...; }
> +... when != pci_free_consistent(x,y,id,z)
> +    when != if (id) { ... pci_free_consistent(x,y,id,z) ... }
>
> +    when != if (y) { ... pci_free_consistent(x,y,id,z) ... }
> +    when != e = (T)id
> +    when exists
> +(
> +return 0;
> +|
> +return 1;
> +|
> +return id;
> +|
> +return@p2 ...;
> +)
> +
> +@script:python depends on report@
> +p1 << search.p1;
> +p2 << search.p2;
> +@@
> +
> +msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on line %s
> and return without freeing on line %s" % (p1[0].line,p2[0].line)
> +coccilib.report.print_report(p2[0],msg)
> +
> +@script:python depends on org@
> +p1 << search.p1;
> +p2 << search.p2;
> +@@
> +
> +msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on line %s
> and return without freeing on line %s" % (p1[0].line,p2[0].line)
> +cocci.print_main(msg,p1)
> +cocci.print_secs("",p2)
>
>
> --
> 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



--
Nicolas Palix
Tel: +33 4 76 51 46 27
http://membres-liglab.imag.fr/palix/

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] scripts: Coccinelle script for pci_free_consistent()
@ 2013-06-25 13:03   ` Nicolas Palix
  0 siblings, 0 replies; 31+ messages in thread
From: Nicolas Palix @ 2013-06-25 13:03 UTC (permalink / raw)
  To: cocci

On Wed, May 8, 2013 at 11:03 PM,  <strnape1@fel.cvut.cz> wrote:
> Created coccinelle script for reporting missing pci_free_consistent() calls.
>
> Signed-off-by: Petr Strnad <strnape1@fel.cvut.cz>

Signed-off-by: Nicolas Palix <nicolas.palix@imag.fr>

> ---
> diff --git a/scripts/coccinelle/free/pci_free_consistent.cocci
> b/scripts/coccinelle/free/pci_free_consistent.cocci
> new file mode 100644
> index 0000000..43600cc
> --- /dev/null
> +++ b/scripts/coccinelle/free/pci_free_consistent.cocci
> @@ -0,0 +1,52 @@
> +/// Find missing pci_free_consistent for every pci_alloc_consistent.
> +///
> +// Confidence: Moderate
> +// Copyright: (C) 2013 Petr Strnad.  GPLv2.
> +// URL: http://coccinelle.lip6.fr/
> +// Keywords: pci_free_consistent, pci_alloc_consistent
> +// Options: --no-includes --include-headers
> +
> +virtual report
> +virtual org
> +
> +@search@
> +local idexpression id;
> +expression x,y,z,e;
> +position p1,p2;
> +type T;
> +@@
> +
> +id = pci_alloc_consistent@p1(x,y,&z)
> +... when != e = id
> +if (id = NULL || ...) { ... return ...; }
> +... when != pci_free_consistent(x,y,id,z)
> +    when != if (id) { ... pci_free_consistent(x,y,id,z) ... }
>
> +    when != if (y) { ... pci_free_consistent(x,y,id,z) ... }
> +    when != e = (T)id
> +    when exists
> +(
> +return 0;
> +|
> +return 1;
> +|
> +return id;
> +|
> +return@p2 ...;
> +)
> +
> +@script:python depends on report@
> +p1 << search.p1;
> +p2 << search.p2;
> +@@
> +
> +msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on line %s
> and return without freeing on line %s" % (p1[0].line,p2[0].line)
> +coccilib.report.print_report(p2[0],msg)
> +
> +@script:python depends on org@
> +p1 << search.p1;
> +p2 << search.p2;
> +@@
> +
> +msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on line %s
> and return without freeing on line %s" % (p1[0].line,p2[0].line)
> +cocci.print_main(msg,p1)
> +cocci.print_secs("",p2)
>
>
> --
> 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



--
Nicolas Palix
Tel: +33 4 76 51 46 27
http://membres-liglab.imag.fr/palix/

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [Cocci] [PATCH] scripts: Coccinelle script for pci_free_consistent()
@ 2013-06-25 13:03   ` Nicolas Palix
  0 siblings, 0 replies; 31+ messages in thread
From: Nicolas Palix @ 2013-06-25 13:03 UTC (permalink / raw)
  To: cocci

On Wed, May 8, 2013 at 11:03 PM,  <strnape1@fel.cvut.cz> wrote:
> Created coccinelle script for reporting missing pci_free_consistent() calls.
>
> Signed-off-by: Petr Strnad <strnape1@fel.cvut.cz>

Signed-off-by: Nicolas Palix <nicolas.palix@imag.fr>

> ---
> diff --git a/scripts/coccinelle/free/pci_free_consistent.cocci
> b/scripts/coccinelle/free/pci_free_consistent.cocci
> new file mode 100644
> index 0000000..43600cc
> --- /dev/null
> +++ b/scripts/coccinelle/free/pci_free_consistent.cocci
> @@ -0,0 +1,52 @@
> +/// Find missing pci_free_consistent for every pci_alloc_consistent.
> +///
> +// Confidence: Moderate
> +// Copyright: (C) 2013 Petr Strnad.  GPLv2.
> +// URL: http://coccinelle.lip6.fr/
> +// Keywords: pci_free_consistent, pci_alloc_consistent
> +// Options: --no-includes --include-headers
> +
> +virtual report
> +virtual org
> +
> + at search@
> +local idexpression id;
> +expression x,y,z,e;
> +position p1,p2;
> +type T;
> +@@
> +
> +id = pci_alloc_consistent at p1(x,y,&z)
> +... when != e = id
> +if (id == NULL || ...) { ... return ...; }
> +... when != pci_free_consistent(x,y,id,z)
> +    when != if (id) { ... pci_free_consistent(x,y,id,z) ... }
>
> +    when != if (y) { ... pci_free_consistent(x,y,id,z) ... }
> +    when != e = (T)id
> +    when exists
> +(
> +return 0;
> +|
> +return 1;
> +|
> +return id;
> +|
> +return at p2 ...;
> +)
> +
> + at script:python depends on report@
> +p1 << search.p1;
> +p2 << search.p2;
> +@@
> +
> +msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on line %s
> and return without freeing on line %s" % (p1[0].line,p2[0].line)
> +coccilib.report.print_report(p2[0],msg)
> +
> + at script:python depends on org@
> +p1 << search.p1;
> +p2 << search.p2;
> +@@
> +
> +msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on line %s
> and return without freeing on line %s" % (p1[0].line,p2[0].line)
> +cocci.print_main(msg,p1)
> +cocci.print_secs("",p2)
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors"
> in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



--
Nicolas Palix
Tel: +33 4 76 51 46 27
http://membres-liglab.imag.fr/palix/

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] scripts: Coccinelle script for pci_free_consistent()
  2013-06-25 13:03   ` Nicolas Palix
  (?)
@ 2013-07-03 13:55     ` Michal Marek
  -1 siblings, 0 replies; 31+ messages in thread
From: Michal Marek @ 2013-07-03 13:55 UTC (permalink / raw)
  To: strnape1; +Cc: Nicolas Palix, kernel-janitors, LKML, Coccinelle, Julia Lawall

On 25.6.2013 15:03, Nicolas Palix wrote:
> On Wed, May 8, 2013 at 11:03 PM,  <strnape1@fel.cvut.cz> wrote:
>> Created coccinelle script for reporting missing pci_free_consistent() calls.
>>
>> Signed-off-by: Petr Strnad <strnape1@fel.cvut.cz>
> 
> Signed-off-by: Nicolas Palix <nicolas.palix@imag.fr>

Applied to kbuild.git#misc. BTW, the patch was malformed at several
places, you mailer broke long lines like this:

>> +msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on line %s
>> and return without freeing on line %s" % (p1[0].line,p2[0].line)

Please send the patch to yourself next time and verify that 'git am' can
apply it, before sending it to the mailing list.

Thanks,
Michal

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] scripts: Coccinelle script for pci_free_consistent()
@ 2013-07-03 13:55     ` Michal Marek
  0 siblings, 0 replies; 31+ messages in thread
From: Michal Marek @ 2013-07-03 13:55 UTC (permalink / raw)
  To: cocci

On 25.6.2013 15:03, Nicolas Palix wrote:
> On Wed, May 8, 2013 at 11:03 PM,  <strnape1@fel.cvut.cz> wrote:
>> Created coccinelle script for reporting missing pci_free_consistent() calls.
>>
>> Signed-off-by: Petr Strnad <strnape1@fel.cvut.cz>
> 
> Signed-off-by: Nicolas Palix <nicolas.palix@imag.fr>

Applied to kbuild.git#misc. BTW, the patch was malformed at several
places, you mailer broke long lines like this:

>> +msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on line %s
>> and return without freeing on line %s" % (p1[0].line,p2[0].line)

Please send the patch to yourself next time and verify that 'git am' can
apply it, before sending it to the mailing list.

Thanks,
Michal

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [Cocci] [PATCH] scripts: Coccinelle script for pci_free_consistent()
@ 2013-07-03 13:55     ` Michal Marek
  0 siblings, 0 replies; 31+ messages in thread
From: Michal Marek @ 2013-07-03 13:55 UTC (permalink / raw)
  To: cocci

On 25.6.2013 15:03, Nicolas Palix wrote:
> On Wed, May 8, 2013 at 11:03 PM,  <strnape1@fel.cvut.cz> wrote:
>> Created coccinelle script for reporting missing pci_free_consistent() calls.
>>
>> Signed-off-by: Petr Strnad <strnape1@fel.cvut.cz>
> 
> Signed-off-by: Nicolas Palix <nicolas.palix@imag.fr>

Applied to kbuild.git#misc. BTW, the patch was malformed at several
places, you mailer broke long lines like this:

>> +msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on line %s
>> and return without freeing on line %s" % (p1[0].line,p2[0].line)

Please send the patch to yourself next time and verify that 'git am' can
apply it, before sending it to the mailing list.

Thanks,
Michal

^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2013-07-03 13:55 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-28 17:04 [PATCH] scripts: Coccinelle script for pci_free_consistent() strnape1
2013-04-28 23:05 ` Julia Lawall
2013-04-29 21:06 ` strnape1
2013-04-29 23:35 ` Julia Lawall
2013-04-30  7:58 ` strnape1
2013-05-01 10:32 ` Julia Lawall
2013-05-02  0:28 ` strnape1
2013-05-02  0:57 ` Julia Lawall
2013-05-02 15:12 ` strnape1
2013-05-06 20:57 ` Nicolas Palix
2013-05-06 21:20 ` strnape1
2013-05-07  6:55 ` Dan Carpenter
2013-05-07  6:56 ` Julia Lawall
2013-05-08 12:20 ` strnape1
2013-05-08 14:49 ` Julia Lawall
2013-05-08 15:46 ` strnape1
2013-05-08 15:52 ` Julia Lawall
2013-05-08 16:28 strnape1
2013-05-08 16:28 ` [Cocci] " strnape1 at fel.cvut.cz
2013-05-08 16:28 ` strnape1
2013-05-08 21:03 strnape1
2013-05-08 21:03 ` strnape1
2013-06-14 13:25 ` Michal Marek
2013-06-14 13:25   ` [Cocci] " Michal Marek
2013-06-14 13:25   ` Michal Marek
2013-06-25 13:03 ` Nicolas Palix
2013-06-25 13:03   ` [Cocci] " Nicolas Palix
2013-06-25 13:03   ` Nicolas Palix
2013-07-03 13:55   ` Michal Marek
2013-07-03 13:55     ` [Cocci] " Michal Marek
2013-07-03 13:55     ` Michal Marek

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.