eno.cocci 547 B

123456789101112131415161718192021
  1. /// The various basic memory allocation functions don't return ERR_PTR
  2. ///
  3. // Confidence: High
  4. // Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2.
  5. // Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2.
  6. // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2.
  7. // URL: http://coccinelle.lip6.fr/
  8. // Comments:
  9. // Options: -no_includes -include_headers
  10. virtual patch
  11. @@
  12. expression x,E;
  13. @@
  14. x = \(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\|kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\)(...)
  15. ... when != x = E
  16. - IS_ERR(x)
  17. + !x