1 // SPDX-License-Identifier: GPL-2.0-only
2 /// NULL check before some freeing functions is not needed.
4 /// Based on checkpatch warning
5 /// "kfree(NULL) is safe this check is probably not required"
6 /// and kfreeaddr.cocci by Julia Lawall.
8 // Copyright: (C) 2014 Fabian Frederick.
10 // Options: --no-includes --include-headers
28 kvfree_sensitive(E, ...);
34 debugfs_remove_recursive(E);
38 kmem_cache_destroy(E);
45 @r depends on context || report || org @
51 * \(kfree@p\|kvfree@p\|kfree_sensitive@p\|kvfree_sensitive@p\|vfree@p\|
52 * debugfs_remove@p\|debugfs_remove_recursive@p\|
53 * usb_free_urb@p\|kmem_cache_destroy@p\|mempool_destroy@p\|
54 * dma_pool_destroy@p\)(E, ...);
56 @script:python depends on org@
60 cocci.print_main("NULL check before that freeing function is not needed", p)
62 @script:python depends on report@
66 msg = "WARNING: NULL check before some freeing functions is not needed."
67 coccilib.report.print_report(p[0], msg)