Skip to content

Commit

Permalink
coccinelle: devm_free: reduce false positives
Browse files Browse the repository at this point in the history
Some files use both a non-devm allocation and a devm_allocation.  Don't
complain about a free when the same function contains a non-devm
allocation.

Signed-off-by: Julia Lawall <[email protected]>
Signed-off-by: Masahiro Yamada <[email protected]>
  • Loading branch information
JuliaLawall authored and masahir0y committed Feb 7, 2018
1 parent 0a5f417 commit e856f3a
Showing 1 changed file with 54 additions and 1 deletion.
55 changes: 54 additions & 1 deletion scripts/coccinelle/free/devm_free.cocci
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,62 @@ expression x;
x = devm_ioport_map(...)
)

@safe depends on context || org || report exists@
expression x;
position p;
@@

(
x = kmalloc(...)
|
x = kvasprintf(...)
|
x = kasprintf(...)
|
x = kzalloc(...)
|
x = kmalloc_array(...)
|
x = kcalloc(...)
|
x = kstrdup(...)
|
x = kmemdup(...)
|
x = get_free_pages(...)
|
x = request_irq(...)
|
x = ioremap(...)
|
x = ioremap_nocache(...)
|
x = ioport_map(...)
)
...
(
kfree@p(x)
|
kzfree@p(x)
|
__krealloc@p(x, ...)
|
krealloc@p(x, ...)
|
free_pages@p(x, ...)
|
free_page@p(x)
|
free_irq@p(x)
|
iounmap@p(x)
|
ioport_unmap@p(x)
)

@pb@
expression r.x;
position p;
position p != safe.p;
@@

(
Expand Down

0 comments on commit e856f3a

Please sign in to comment.