summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorJulia Lawall <Julia.Lawall@inria.fr>2026-08-09 18:43:36 +0200
committerJulia Lawall <Julia.Lawall@inria.fr>2026-08-23 22:12:10 +0200
commit8c59f5c467aff29d9d8088e07b6ca34926f6151d (patch)
tree315460aefd578ee2267c8190725487dd8bc1c064 /scripts
parent707f8e0ddf3f730c15e5c18b346d4258ddb46868 (diff)
downloadlinux-8c59f5c467aff29d9d8088e07b6ca34926f6151d.tar.gz
linux-8c59f5c467aff29d9d8088e07b6ca34926f6151d.zip
scripts: coccinelle: devm_free: reduce false positives
False positives could be introduced due to allocations using the new _obj functions. Add these to the "safe" rule accordingly. False positives could also be introduced when the same variable name has two possible types. Incorporate type information to avoid reporting this case This does lead to false negatives when no type information is available. Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr> Reported-by: Ricardo Ribalda <ribalda@chromium.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/coccinelle/free/devm_free.cocci15
1 files changed, 12 insertions, 3 deletions
diff --git a/scripts/coccinelle/free/devm_free.cocci b/scripts/coccinelle/free/devm_free.cocci
index 0880729badbc..947d7e685655 100644
--- a/scripts/coccinelle/free/devm_free.cocci
+++ b/scripts/coccinelle/free/devm_free.cocci
@@ -26,7 +26,8 @@ virtual report
virtual context
@r depends on context || org || report@
-expression x;
+type T;
+T x;
@@
(
@@ -56,19 +57,27 @@ expression x;
)
@safe depends on context || org || report exists@
-expression x;
+r.T x;
position p;
@@
(
x = kmalloc(...)
|
+ x = kmalloc_obj(...)
+|
+ x = kmalloc_objs(...)
+|
x = kvasprintf(...)
|
x = kasprintf(...)
|
x = kzalloc(...)
|
+ x = kzalloc_obj(...)
+|
+ x = kzalloc_objs(...)
+|
x = kmalloc_array(...)
|
x = kcalloc(...)
@@ -105,7 +114,7 @@ position p;
)
@pb@
-expression r.x;
+r.T r.x;
position p != safe.p;
@@