1 // SPDX-License-Identifier: GPL-2.0-only
2 /// Find missing unlocks. This semantic match considers the specific case
3 /// where the unlock is missing from an if branch, and there is a lock
4 /// before the if and an unlock after the if. False positives are due to
5 /// cases where the if branch represents a case where the function is
6 /// supposed to exit with the lock held, or where there is some preceding
7 /// function call that releases the lock.
9 // Confidence: Moderate
10 // Copyright: (C) 2010-2012 Nicolas Palix.
11 // Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6.
12 // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.
13 // URL: http://coccinelle.lip6.fr/
15 // Options: --no-includes --include-headers
60 for(...;...;...) { <+... return@r ...; ...+> }
65 position up != prelocked.p1;
67 identifier lock,unlock;
81 @script:python depends on org@
88 cocci.print_main(lock,p)
89 cocci.print_secs(unlock,p2)
91 @script:python depends on report@
98 msg = "preceding lock on line %s" % (p[0].line)
99 coccilib.report.print_report(p2[0],msg)