xref: /openbmc/linux/scripts/coccinelle/free/kfreeaddr.cocci (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
17f904d7eSThomas Gleixner// SPDX-License-Identifier: GPL-2.0-only
261cb48c3SJulia Lawall/// Free of a structure field
361cb48c3SJulia Lawall///
461cb48c3SJulia Lawall// Confidence: High
57f904d7eSThomas Gleixner// Copyright: (C) 2013 Julia Lawall, INRIA/LIP6.
6*f01701ceSJulia Lawall// URL: https://coccinelle.gitlabpages.inria.fr/website
761cb48c3SJulia Lawall// Comments:
893f14468SNicolas Palix// Options: --no-includes --include-headers
961cb48c3SJulia Lawall
1061cb48c3SJulia Lawallvirtual org
1161cb48c3SJulia Lawallvirtual report
1261cb48c3SJulia Lawallvirtual context
1361cb48c3SJulia Lawall
1461cb48c3SJulia Lawall@r depends on context || report || org @
1561cb48c3SJulia Lawallexpression e;
1661cb48c3SJulia Lawallidentifier f;
1761cb48c3SJulia Lawallposition p;
1861cb48c3SJulia Lawall@@
1961cb48c3SJulia Lawall
206dd9379eSYann Droneaud(
2161cb48c3SJulia Lawall* kfree@p(&e->f)
226dd9379eSYann Droneaud|
23453431a5SWaiman Long* kfree_sensitive@p(&e->f)
246dd9379eSYann Droneaud)
2561cb48c3SJulia Lawall
2661cb48c3SJulia Lawall@script:python depends on org@
2761cb48c3SJulia Lawallp << r.p;
2861cb48c3SJulia Lawall@@
2961cb48c3SJulia Lawall
3061cb48c3SJulia Lawallcocci.print_main("kfree",p)
3161cb48c3SJulia Lawall
3261cb48c3SJulia Lawall@script:python depends on report@
3361cb48c3SJulia Lawallp << r.p;
3461cb48c3SJulia Lawall@@
3561cb48c3SJulia Lawall
366dd9379eSYann Droneaudmsg = "ERROR: invalid free of structure field"
3761cb48c3SJulia Lawallcoccilib.report.print_report(p[0],msg)
38