[Cocci] [PATCH v2 1/3] coccinelle: also catch kzfree() issues
Since commit 3ef0e5ba4673 ('slab: introduce kzfree()'), kfree() is no more the only function to be considered: kzfree() should be recognized too. In particular, kzfree() must not be called on memory allocated through devm_*() functions. Cc: Johannes Weiner Signed-off-by: Yann Droneaud --- scripts/coccinelle/free/devm_free.cocci | 2 ++ scripts/coccinelle/free/ifnullfree.cocci | 4 +++- scripts/coccinelle/free/kfree.cocci | 18 +++--- scripts/coccinelle/free/kfreeaddr.cocci | 6 +- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/scripts/coccinelle/free/devm_free.cocci b/scripts/coccinelle/free/devm_free.cocci index 3d9349012bb3..83c03adec1c5 100644 --- a/scripts/coccinelle/free/devm_free.cocci +++ b/scripts/coccinelle/free/devm_free.cocci @@ -48,6 +48,8 @@ position p; ( * kfree@p(x) | +* kzfree@p(x) +| * free_irq@p(x) | * iounmap@p(x) diff --git a/scripts/coccinelle/free/ifnullfree.cocci b/scripts/coccinelle/free/ifnullfree.cocci index 52bd235286fa..14a4cd98e83b 100644 --- a/scripts/coccinelle/free/ifnullfree.cocci +++ b/scripts/coccinelle/free/ifnullfree.cocci @@ -20,6 +20,8 @@ expression E; ( kfree(E); | + kzfree(E); +| debugfs_remove(E); | debugfs_remove_recursive(E); @@ -39,7 +41,7 @@ position p; @@ * if (E != NULL) -* \(kfree@p\|debugfs_remove@p\|debugfs_remove_recursive@p\| +* \(kfree@p\|kzfree@p\|debugfs_remove@p\|debugfs_remove_recursive@p\| * usb_free_urb@p\|kmem_cache_destroy@p\|mempool_destroy@p\| * dma_pool_destroy@p\)(E); diff --git a/scripts/coccinelle/free/kfree.cocci b/scripts/coccinelle/free/kfree.cocci index 577b78056990..ac438da4fd7b 100644 --- a/scripts/coccinelle/free/kfree.cocci +++ b/scripts/coccinelle/free/kfree.cocci @@ -20,7 +20,11 @@ expression E; position p1; @@ -kfree@p1(E) +( +* kfree@p1(E) +| +* kzfree@p1(E) +) @print expression@ constant char [] c; @@ -60,7 +64,11 @@ position ok; @@ while (1) { ... - kfree@ok(E) +( +* kfree@ok(E) +| +* kzfree@ok(E) +) ... when != break; when != goto l; when forall @@ -74,7 +82,11 @@ statement S; position free.p1!=loop.ok,p2!={print.p,sz.p}; @@ -kfree@p1(E,...) +( +* kfree@p1(E,...) +| +* kzfree@p1(E,...) +) ... ( iter(...,subE,...) S // no use diff --git a/scripts/coccinelle/free/kfreeaddr.cocci b/scripts/coccinelle/free/kfreeaddr.cocci index ce8aacc314cb..d46063b1db8b 100644 --- a/scripts/coccinelle/free/kfreeaddr.cocci +++ b/scripts/coccinelle/free/kfreeaddr.cocci @@ -16,7 +16,11 @@ identifier f; position p; @@ +( * kfree@p(&e->f) +| +* kzfree@p(&e->f) +) @script:python depends on org@ p << r.p; @@ -28,5 +32,5 @@ cocci.print_main("kfree",p) p << r.p; @@ -msg = "ERROR: kfree of structure field" +msg = "ERROR: invalid free of structure field" coccilib.report.print_report(p[0],msg) -- 2.7.4 ___ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci
Re: [Cocci] [PATCH v2 1/3] coccinelle: also catch kzfree() issues
On Mon, 23 May 2016, Yann Droneaud wrote: > Since commit 3ef0e5ba4673 ('slab: introduce kzfree()'), > kfree() is no more the only function to be considered: > kzfree() should be recognized too. > > In particular, kzfree() must not be called on memory > allocated through devm_*() functions. > > Cc: Johannes Weiner > Signed-off-by: Yann Droneaud Acked-by: Julia Lawall > --- > scripts/coccinelle/free/devm_free.cocci | 2 ++ > scripts/coccinelle/free/ifnullfree.cocci | 4 +++- > scripts/coccinelle/free/kfree.cocci | 18 +++--- > scripts/coccinelle/free/kfreeaddr.cocci | 6 +- > 4 files changed, 25 insertions(+), 5 deletions(-) > > diff --git a/scripts/coccinelle/free/devm_free.cocci > b/scripts/coccinelle/free/devm_free.cocci > index 3d9349012bb3..83c03adec1c5 100644 > --- a/scripts/coccinelle/free/devm_free.cocci > +++ b/scripts/coccinelle/free/devm_free.cocci > @@ -48,6 +48,8 @@ position p; > ( > * kfree@p(x) > | > +* kzfree@p(x) > +| > * free_irq@p(x) > | > * iounmap@p(x) > diff --git a/scripts/coccinelle/free/ifnullfree.cocci > b/scripts/coccinelle/free/ifnullfree.cocci > index 52bd235286fa..14a4cd98e83b 100644 > --- a/scripts/coccinelle/free/ifnullfree.cocci > +++ b/scripts/coccinelle/free/ifnullfree.cocci > @@ -20,6 +20,8 @@ expression E; > ( >kfree(E); > | > + kzfree(E); > +| >debugfs_remove(E); > | >debugfs_remove_recursive(E); > @@ -39,7 +41,7 @@ position p; > @@ > > * if (E != NULL) > -*\(kfree@p\|debugfs_remove@p\|debugfs_remove_recursive@p\| > +*\(kfree@p\|kzfree@p\|debugfs_remove@p\|debugfs_remove_recursive@p\| > * usb_free_urb@p\|kmem_cache_destroy@p\|mempool_destroy@p\| > * dma_pool_destroy@p\)(E); > > diff --git a/scripts/coccinelle/free/kfree.cocci > b/scripts/coccinelle/free/kfree.cocci > index 577b78056990..ac438da4fd7b 100644 > --- a/scripts/coccinelle/free/kfree.cocci > +++ b/scripts/coccinelle/free/kfree.cocci > @@ -20,7 +20,11 @@ expression E; > position p1; > @@ > > -kfree@p1(E) > +( > +* kfree@p1(E) > +| > +* kzfree@p1(E) > +) > > @print expression@ > constant char [] c; > @@ -60,7 +64,11 @@ position ok; > @@ > > while (1) { ... > - kfree@ok(E) > +( > +* kfree@ok(E) > +| > +* kzfree@ok(E) > +) >... when != break; >when != goto l; >when forall > @@ -74,7 +82,11 @@ statement S; > position free.p1!=loop.ok,p2!={print.p,sz.p}; > @@ > > -kfree@p1(E,...) > +( > +* kfree@p1(E,...) > +| > +* kzfree@p1(E,...) > +) > ... > ( > iter(...,subE,...) S // no use > diff --git a/scripts/coccinelle/free/kfreeaddr.cocci > b/scripts/coccinelle/free/kfreeaddr.cocci > index ce8aacc314cb..d46063b1db8b 100644 > --- a/scripts/coccinelle/free/kfreeaddr.cocci > +++ b/scripts/coccinelle/free/kfreeaddr.cocci > @@ -16,7 +16,11 @@ identifier f; > position p; > @@ > > +( > * kfree@p(&e->f) > +| > +* kzfree@p(&e->f) > +) > > @script:python depends on org@ > p << r.p; > @@ -28,5 +32,5 @@ cocci.print_main("kfree",p) > p << r.p; > @@ > > -msg = "ERROR: kfree of structure field" > +msg = "ERROR: invalid free of structure field" > coccilib.report.print_report(p[0],msg) > -- > 2.7.4 > > ___ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci
Re: [Cocci] [PATCH v2 1/3] coccinelle: also catch kzfree() issues
On 2016-05-23 17:18, Julia Lawall wrote: > > > On Mon, 23 May 2016, Yann Droneaud wrote: > >> Since commit 3ef0e5ba4673 ('slab: introduce kzfree()'), >> kfree() is no more the only function to be considered: >> kzfree() should be recognized too. >> >> In particular, kzfree() must not be called on memory >> allocated through devm_*() functions. >> >> Cc: Johannes Weiner >> Signed-off-by: Yann Droneaud > > Acked-by: Julia Lawall Hi Julia, does your ACK apply to the other two patches as well? Thanks, Michal ___ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci
Re: [Cocci] [PATCH v2 1/3] coccinelle: also catch kzfree() issues
On Mon, 20 Jun 2016, Michal Marek wrote: > On 2016-05-23 17:18, Julia Lawall wrote: > > > > > > On Mon, 23 May 2016, Yann Droneaud wrote: > > > >> Since commit 3ef0e5ba4673 ('slab: introduce kzfree()'), > >> kfree() is no more the only function to be considered: > >> kzfree() should be recognized too. > >> > >> In particular, kzfree() must not be called on memory > >> allocated through devm_*() functions. > >> > >> Cc: Johannes Weiner > >> Signed-off-by: Yann Droneaud > > > > Acked-by: Julia Lawall > > Hi Julia, > > does your ACK apply to the other two patches as well? Sorry, I seem to have missed the other two. I have reviewed them now, and the ack applies to all three. Thanks for checking on it. julia ___ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci
Re: [Cocci] [PATCH v2 1/3] coccinelle: also catch kzfree() issues
Dne 20.6.2016 v 22:21 Julia Lawall napsal(a): > > > On Mon, 20 Jun 2016, Michal Marek wrote: > >> On 2016-05-23 17:18, Julia Lawall wrote: >>> >>> >>> On Mon, 23 May 2016, Yann Droneaud wrote: >>> Since commit 3ef0e5ba4673 ('slab: introduce kzfree()'), kfree() is no more the only function to be considered: kzfree() should be recognized too. In particular, kzfree() must not be called on memory allocated through devm_*() functions. Cc: Johannes Weiner Signed-off-by: Yann Droneaud >>> >>> Acked-by: Julia Lawall >> >> Hi Julia, >> >> does your ACK apply to the other two patches as well? > > Sorry, I seem to have missed the other two. I have reviewed them now, and > the ack applies to all three. Thanks for checking on it. Np. Applied to kbuild.git#misc now. Michal ___ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci
Re: [Cocci] [PATCH v2 1/3] coccinelle: also catch kzfree() issues
Hi, Le mardi 21 juin 2016 à 11:43 +0200, Michal Marek a écrit : > Dne 20.6.2016 v 22:21 Julia Lawall napsal(a): > > On Mon, 20 Jun 2016, Michal Marek wrote: > > On 2016-05-23 17:18, Julia Lawall wrote: > > > > On Mon, 23 May 2016, Yann Droneaud wrote: > > > > > > > > > Since commit 3ef0e5ba4673 ('slab: introduce kzfree()'), > > > > > kfree() is no more the only function to be considered: > > > > > kzfree() should be recognized too. > > > > > > > > > > In particular, kzfree() must not be called on memory > > > > > allocated through devm_*() functions. > > > > > > > > > > Cc: Johannes Weiner > > > > > Signed-off-by: Yann Droneaud > > > > > > > > Acked-by: Julia Lawall > > > > > > Hi Julia, > > > > > > does your ACK apply to the other two patches as well? > > > > Sorry, I seem to have missed the other two. I have reviewed them > > now, and the ack applies to all three. Thanks for checking on it. > Back in February, those two other patches were already Acked-by: http://lkml.kernel.org/r/alpine.DEB.2.10.1602161818100.2685@hadrien http://lkml.kernel.org/r/alpine.DEB.2.10.1602161819340.2685@hadrien I've (re)sent them with added Acked-by:, and thought it would not require further Acked-by:. Anyway, this one was new and required proper review. Thanks a lot. > Np. Applied to kbuild.git#misc now. > Thanks a lot. -- Yann Droneaud OPTEYA ___ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci
Re: [Cocci] [PATCH v2 1/3] coccinelle: also catch kzfree() issues
On Tue, 21 Jun 2016, Yann Droneaud wrote: > Hi, > > Le mardi 21 juin 2016 à 11:43 +0200, Michal Marek a écrit : > > Dne 20.6.2016 v 22:21 Julia Lawall napsal(a): > > > On Mon, 20 Jun 2016, Michal Marek wrote: > > > On 2016-05-23 17:18, Julia Lawall wrote: > > > > > On Mon, 23 May 2016, Yann Droneaud wrote: > > > > > > > > > > > Since commit 3ef0e5ba4673 ('slab: introduce kzfree()'), > > > > > > kfree() is no more the only function to be considered: > > > > > > kzfree() should be recognized too. > > > > > > > > > > > > In particular, kzfree() must not be called on memory > > > > > > allocated through devm_*() functions. > > > > > > > > > > > > Cc: Johannes Weiner > > > > > > Signed-off-by: Yann Droneaud > > > > > > > > > > Acked-by: Julia Lawall > > > > > > > > Hi Julia, > > > > > > > > does your ACK apply to the other two patches as well? > > > > > > Sorry, I seem to have missed the other two. I have reviewed them > > > now, and the ack applies to all three. Thanks for checking on it. > > > > Back in February, those two other patches were already Acked-by: > > http://lkml.kernel.org/r/alpine.DEB.2.10.1602161818100.2685@hadrien > http://lkml.kernel.org/r/alpine.DEB.2.10.1602161819340.2685@hadrien > > I've (re)sent them with added Acked-by:, and thought it would not > require further Acked-by:. > > Anyway, this one was new and required proper review. Thanks a lot. Thanks for the reminder. Since they are comitted now, things are going in the right direction. julia___ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci