17f904d7eSThomas Gleixner// SPDX-License-Identifier: GPL-2.0-only 24a05f067SJulia Lawall/// PTR_ERR should be applied before its argument is reassigned, typically 34a05f067SJulia Lawall/// to NULL 44a05f067SJulia Lawall/// 54a05f067SJulia Lawall// Confidence: High 67f904d7eSThomas Gleixner// Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. 77f904d7eSThomas Gleixner// Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. 8*f01701ceSJulia Lawall// URL: https://coccinelle.gitlabpages.inria.fr/website 94a05f067SJulia Lawall// Comments: 1093f14468SNicolas Palix// Options: --no-includes --include-headers 114a05f067SJulia Lawall 124a05f067SJulia Lawallvirtual org 134a05f067SJulia Lawallvirtual report 144a05f067SJulia Lawallvirtual context 154a05f067SJulia Lawall 164a05f067SJulia Lawall@r exists@ 174a05f067SJulia Lawallexpression e,e1; 184a05f067SJulia Lawallconstant c; 194a05f067SJulia Lawallposition p1,p2; 204a05f067SJulia Lawall@@ 214a05f067SJulia Lawall 224a05f067SJulia Lawall*e@p1 = c 234a05f067SJulia Lawall... when != e = e1 244a05f067SJulia Lawall when != &e 254a05f067SJulia Lawall when != true IS_ERR(e) 264a05f067SJulia Lawall*PTR_ERR@p2(e) 274a05f067SJulia Lawall 284a05f067SJulia Lawall@script:python depends on org@ 294a05f067SJulia Lawallp1 << r.p1; 304a05f067SJulia Lawallp2 << r.p2; 314a05f067SJulia Lawall@@ 324a05f067SJulia Lawall 334a05f067SJulia Lawallcocci.print_main("PTR_ERR",p2) 344a05f067SJulia Lawallcocci.print_secs("assignment",p1) 354a05f067SJulia Lawall 364a05f067SJulia Lawall@script:python depends on report@ 374a05f067SJulia Lawallp1 << r.p1; 384a05f067SJulia Lawallp2 << r.p2; 394a05f067SJulia Lawall@@ 404a05f067SJulia Lawall 414a05f067SJulia Lawallmsg = "ERROR: PTR_ERR applied after initialization to constant on line %s" % (p1[0].line) 424a05f067SJulia Lawallcoccilib.report.print_report(p2[0],msg) 43