1 // SPDX-License-Identifier: GPL-2.0 2 /// Make sure calls to d_find_alias() have a corresponding call to dput(). 3 // 4 // Keywords: d_find_alias, dput 5 // 6 // Confidence: Moderate 7 // URL: https://coccinelle.gitlabpages.inria.fr/website 8 // Options: --include-headers 9 10 virtual context 11 virtual org 12 virtual patch 13 virtual report 14 15 @r exists@ 16 local idexpression struct dentry *dent; 17 expression E, E1; 18 statement S1, S2; 19 position p1, p2; 20 @@ 21 ( 22 if (!(dent@p1 = d_find_alias(...))) S1 23 | 24 dent@p1 = d_find_alias(...) 25 ) 26 27 <...when != dput(dent) 28 when != if (...) { <+... dput(dent) ...+> } 29 when != true !dent || ... 30 when != dent = E 31 when != E = dent 32 if (!dent || ...) S2 33 ...> 34 ( 35 return <+...dent...+>; 36 | 37 return @p2 ...; 38 | 39 dent@p2 = E1; 40 | 41 E1 = dent; 42 ) 43 44 @depends on context@ 45 local idexpression struct dentry *r.dent; 46 position r.p1,r.p2; 47 @@ 48 * dent@p1 = ... 49 ... 50 ( 51 * return@p2 ...; 52 | 53 * dent@p2 54 ) 55 56 57 @script:python depends on org@ 58 p1 << r.p1; 59 p2 << r.p2; 60 @@ 61 cocci.print_main("Missing call to dput()",p1) 62 cocci.print_secs("",p2) 63 64 @depends on patch@ 65 local idexpression struct dentry *r.dent; 66 position r.p2; 67 @@ 68 ( 69 + dput(dent); 70 return @p2 ...; 71 | 72 + dput(dent); 73 dent@p2 = ...; 74 ) 75 76 @script:python depends on report@ 77 p1 << r.p1; 78 p2 << r.p2; 79 @@ 80 msg = "Missing call to dput() at line %s." 81 coccilib.report.print_report(p1[0], msg % (p2[0].line))
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.