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 nested lock+irqsave functions that use the same flags variables
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3) ///
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4) // Confidence: High
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) // Copyright: (C) 2010-2012 Nicolas Palix.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) // Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) // URL: http://coccinelle.lip6.fr/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) // Comments:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) // Options: --no-includes --include-headers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) virtual context
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) virtual org
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) virtual report
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) @r exists@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) expression lock1,lock2,flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) position p1,p2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) (
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) spin_lock_irqsave@p1(lock1,flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) read_lock_irqsave@p1(lock1,flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) write_lock_irqsave@p1(lock1,flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) ... when != flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) (
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) spin_lock_irqsave(lock1,flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) read_lock_irqsave(lock1,flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) write_lock_irqsave(lock1,flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) spin_lock_irqsave@p2(lock2,flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) read_lock_irqsave@p2(lock2,flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) write_lock_irqsave@p2(lock2,flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) @d exists@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) expression f <= r.flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) expression lock1,lock2,flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) position r.p1, r.p2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) (
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) *spin_lock_irqsave@p1(lock1,flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) *read_lock_irqsave@p1(lock1,flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) *write_lock_irqsave@p1(lock1,flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) ... when != f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) (
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) *spin_lock_irqsave@p2(lock2,flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) *read_lock_irqsave@p2(lock2,flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) *write_lock_irqsave@p2(lock2,flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) // ----------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) @script:python depends on d && org@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) p1 << r.p1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) p2 << r.p2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) cocci.print_main("original lock",p1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) cocci.print_secs("nested lock+irqsave that reuses flags",p2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) @script:python depends on d && report@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) p1 << r.p1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) p2 << r.p2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) @@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) msg="ERROR: nested lock+irqsave that reuses flags from line %s." % (p1[0].line)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) coccilib.report.print_report(p2[0], msg)