summaryrefslogtreecommitdiff
path: root/scripts/coccinelle/locks
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/coccinelle/locks')
-rw-r--r--scripts/coccinelle/locks/double_lock.cocci15
-rw-r--r--scripts/coccinelle/locks/mini_lock.cocci24
2 files changed, 36 insertions, 3 deletions
diff --git a/scripts/coccinelle/locks/double_lock.cocci b/scripts/coccinelle/locks/double_lock.cocci
index 619cfc714409..381060849a7b 100644
--- a/scripts/coccinelle/locks/double_lock.cocci
+++ b/scripts/coccinelle/locks/double_lock.cocci
@@ -38,7 +38,20 @@ write_lock@p1
write_trylock@p1
) (E1@p,...);
-@balanced@
+@r_candidate exists@
+expression x <= locked.E1;
+expression locked.E1;
+expression E2;
+identifier lock;
+position locked.p,p1,p2;
+@@
+
+lock@p1 (E1@p,...);
+... when != E1
+ when != \(x = E2\|&x\)
+lock@p2 (E1,...);
+
+@balanced depends on r_candidate@
position p1 != locked.p1;
position locked.p;
identifier lock,unlock;
diff --git a/scripts/coccinelle/locks/mini_lock.cocci b/scripts/coccinelle/locks/mini_lock.cocci
index 71065d8a5d54..c65241c895ff 100644
--- a/scripts/coccinelle/locks/mini_lock.cocci
+++ b/scripts/coccinelle/locks/mini_lock.cocci
@@ -53,11 +53,31 @@ spin_lock_irq@p1
spin_lock_irqsave@p1
) (E1@p,...);
-@looped@
+@err_candidate exists@
+expression E1;
+position prelocked.p;
+position up != prelocked.p1;
+position rc;
+identifier lock,unlock;
+@@
+
+lock(E1@p,...);
+... when != E1
+ when any
+if (...) {
+ ... when != E1
+ return@rc ...;
+}
+... when != E1
+ when any
+unlock@up(E1,...);
+
+@looped exists@
+position err_candidate.rc;
position r;
@@
-for(...;...;...) { <+... return@r ...; ...+> }
+for(...;...;...) { <+... return@rc@r ...; ...+> }
@err exists@
expression E1;