target/mips: Remove XBurst Media eXtension Unit dead code
[qemu/ar7.git] / scripts / coccinelle / error-use-after-free.cocci
blob72ae9fdebfa120560e14ab6aaeba8fa00dc64a3a
1 // Find and fix trivial use-after-free of Error objects
2 //
3 // Copyright (c) 2020 Virtuozzo International GmbH.
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License as
7 // published by the Free Software Foundation; either version 2 of the
8 // License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program.  If not, see
17 // <http://www.gnu.org/licenses/>.
19 // How to use:
20 // spatch --sp-file scripts/coccinelle/error-use-after-free.cocci \
21 //  --macro-file scripts/cocci-macro-file.h --in-place \
22 //  --no-show-diff ( FILES... | --use-gitgrep . )
24 @ exists@
25 identifier fn, fn2;
26 expression err;
29  fn(...)
30  {
31      <...
33      error_free(err);
34 +    err = NULL;
36      error_report_err(err);
37 +    err = NULL;
39      error_reportf_err(err, ...);
40 +    err = NULL;
42      warn_report_err(err);
43 +    err = NULL;
45      warn_reportf_err(err, ...);
46 +    err = NULL;
48      ... when != err = NULL
49          when != exit(...)
50      fn2(..., err, ...)
51      ...>
52  }