1 /// This semantic patch looks for kmalloc etc that are not followed by a
2 /// NULL check. It only gives a report in the case where there is some
3 /// error handling code later in the function, which may be helpful
4 /// in determining what the error handling code for the call to kmalloc etc
8 // Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2.
9 // Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2.
10 // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2.
11 // URL: http://coccinelle.lip6.fr/
13 // Options: -no_includes -include_headers
27 \(x == NULL \| x != NULL\)
29 @fixed depends on context && !org && !report@
31 position p1 != withtest.p;
33 position any withtest.p;
37 *x@p1 = \(kmalloc\|kzalloc\|kcalloc\)(...);
42 // ------------------------------------------------------------------------
44 @rfixed depends on (org || report) && !context exists@
46 position p1 != withtest.p;
49 position any withtest.p;
53 x@p1 = \(kmalloc\|kzalloc\|kcalloc\)(...);
58 @script:python depends on org@
63 cocci.print_main("alloc call",p1)
64 cocci.print_secs("possible model",p2)
66 @script:python depends on report@
71 msg = "alloc with no test, possible model on line %s" % (p2[0].line)
72 coccilib.report.print_report(p1[0],msg)