Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /// Find missing unlocks.  This semantic match considers the specific case
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3) /// where the unlock is missing from an if branch, and there is a lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4) /// before the if and an unlock after the if.  False positives are due to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) /// cases where the if branch represents a case where the function is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) /// supposed to exit with the lock held, or where there is some preceding
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) /// function call that releases the lock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) ///
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) // Confidence: Moderate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) // Copyright: (C) 2010-2012 Nicolas Palix.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) // Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) // URL: http://coccinelle.lip6.fr/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) // Comments:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) // Options: --no-includes --include-headers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) virtual context
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) virtual org
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) virtual report
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) @prelocked@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) position p1,p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) expression E1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) (
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) mutex_lock@p1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) mutex_trylock@p1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) spin_lock@p1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) spin_trylock@p1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) read_lock@p1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) read_trylock@p1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) write_lock@p1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) write_trylock@p1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) read_lock_irq@p1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) write_lock_irq@p1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) read_lock_irqsave@p1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) write_lock_irqsave@p1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) spin_lock_irq@p1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) spin_lock_irqsave@p1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) ) (E1@p,...);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) @looped@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) position r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) for(...;...;...) { <+... return@r ...; ...+> }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) @err exists@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) expression E1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) position prelocked.p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) position up != prelocked.p1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) position r!=looped.r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) identifier lock,unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) *lock(E1@p,...);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) ... when != E1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)     when any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) if (...) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)   ... when != E1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) *  return@r ...;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) ... when != E1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)     when any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) *unlock@up(E1,...);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) @script:python depends on org@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) p << prelocked.p1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) lock << err.lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) unlock << err.unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) p2 << err.r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) cocci.print_main(lock,p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) cocci.print_secs(unlock,p2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) @script:python depends on report@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) p << prelocked.p1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) lock << err.lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) unlock << err.unlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) p2 << err.r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) msg = "preceding lock on line %s" % (p[0].line)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) coccilib.report.print_report(p2[0],msg)