[Cocci] [PATCH v6] coccinelle: api: add kvfree script

2020-07-31 Thread Denis Efremov
Check that alloc and free types of functions match each other. Signed-off-by: Denis Efremov --- Changes in v2: - Lines are limited to 80 characters where possible - Confidence changed from High to Medium because of fs/btrfs/send.c:1119 false-positive - __vmalloc_area_node() explicitly

Re: [Cocci] Match variable declaration with init expression

2020-07-31 Thread Julia Lawall
On Fri, 31 Jul 2020, Denis Efremov wrote: > Hi, > > This pattern: > - E = kzalloc(size, flags | __GFP_NOWARN); > - if (\(!E\|E == null\))@p > - E = vzalloc(size); > + E = kvzalloc(size, flags); > > matches this code: > void *p; > p = kzalloc(size, gfp | __GFP_NOWARN); > > if (!p) > p =

Re: [Cocci] [v4] coccinelle: api: add kvfree script

2020-07-31 Thread Julia Lawall
On Fri, 31 Jul 2020, Markus Elfring wrote: > > +msg = "WARNING: kmalloc is used to allocate this memory at line %s" % > > (k[0].line) > > +coccilib.org.print_todo(p[0], msg) > > * I find the diagnostic text insufficient. > >>> > >>> I also find the message not very

[Cocci] Match variable declaration with init expression

2020-07-31 Thread Denis Efremov
Hi, This pattern: - E = kzalloc(size, flags | __GFP_NOWARN); - if (\(!E\|E == null\))@p - E = vzalloc(size); + E = kvzalloc(size, flags); matches this code: void *p; p = kzalloc(size, gfp | __GFP_NOWARN); if (!p) p = vzalloc(size); But not this: void *p = kzalloc(size, gfp |

[Cocci] [PATCH v5] coccinelle: api: add kvfree script

2020-07-31 Thread Denis Efremov
Check that alloc and free types of functions match each other. Signed-off-by: Denis Efremov --- Changes in v2: - Lines are limited to 80 characters where possible - Confidence changed from High to Medium because of fs/btrfs/send.c:1119 false-positive - __vmalloc_area_node() explicitly

Re: [Cocci] [PATCH v4] coccinelle: api: add kvfree script

2020-07-31 Thread Julia Lawall
> > > > Do the checks for the opportunities for kvmalloc really belong in this > > rule? That issue is not mentioned in the commit log or the description of > > the semantic patch. > > I added this at the last moment. It was easy enough to add it based on > existing > patterns. I will add

Re: [Cocci] [PATCH v4] coccinelle: api: add kvfree script

2020-07-31 Thread Julia Lawall
On Fri, 31 Jul 2020, Markus Elfring wrote: > >>> +msg = "WARNING: kmalloc is used to allocate this memory at line %s" % > >>> (k[0].line) > >>> +coccilib.org.print_todo(p[0], msg) > >> > >> * I find the diagnostic text insufficient. > > > > I also find the message not very informative. > > Is

Re: [Cocci] [PATCH v4] coccinelle: api: add kvfree script

2020-07-31 Thread Denis Efremov
> With the current patch mode, I got some changes in a recent linux-next. > Have you sent patches for these issues? For mellanox, I've sent these patches: https://lkml.org/lkml/2020/6/5/901 https://lkml.org/lkml/2020/6/1/713 They were accepted. I see two new places in mellanox driver in