aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2020-04-05 18:28:17 +0100
committerPeter Maydell <peter.maydell@linaro.org>2020-04-05 18:28:17 +0100
commit547522cd3d2b006d249457f4c06bd82c8c247d1f (patch)
tree760bc12e74b1c1efb0c829c6f24a6a1b232b7dd0 /scripts
parent146aa0f104bb3bf88e43c4082a0bfc4bbda4fbd8 (diff)
parent6a4a38530e70f3917a58d71d4d08e28bd8146015 (diff)
downloadqemu-547522cd3d2b006d249457f4c06bd82c8c247d1f.zip
qemu-547522cd3d2b006d249457f4c06bd82c8c247d1f.tar.gz
qemu-547522cd3d2b006d249457f4c06bd82c8c247d1f.tar.bz2
Merge remote-tracking branch 'remotes/armbru/tags/pull-error-2020-04-04' into staging
Error reporting patches for 2020-04-04 # gpg: Signature made Sat 04 Apr 2020 13:19:40 BST # gpg: using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653 # gpg: issuer "armbru@redhat.com" # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full] # gpg: aka "Markus Armbruster <armbru@pond.sub.org>" [full] # Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867 4E5F 3870 B400 EB91 8653 * remotes/armbru/tags/pull-error-2020-04-04: qga/commands-posix: fix use after free of local_err dump/win_dump: fix use after free of err scripts/coccinelle: add error-use-after-free.cocci Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/coccinelle/error-use-after-free.cocci52
1 files changed, 52 insertions, 0 deletions
diff --git a/scripts/coccinelle/error-use-after-free.cocci b/scripts/coccinelle/error-use-after-free.cocci
new file mode 100644
index 0000000..72ae9fd
--- /dev/null
+++ b/scripts/coccinelle/error-use-after-free.cocci
@@ -0,0 +1,52 @@
+// Find and fix trivial use-after-free of Error objects
+//
+// Copyright (c) 2020 Virtuozzo International GmbH.
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see
+// <http://www.gnu.org/licenses/>.
+//
+// How to use:
+// spatch --sp-file scripts/coccinelle/error-use-after-free.cocci \
+// --macro-file scripts/cocci-macro-file.h --in-place \
+// --no-show-diff ( FILES... | --use-gitgrep . )
+
+@ exists@
+identifier fn, fn2;
+expression err;
+@@
+
+ fn(...)
+ {
+ <...
+(
+ error_free(err);
++ err = NULL;
+|
+ error_report_err(err);
++ err = NULL;
+|
+ error_reportf_err(err, ...);
++ err = NULL;
+|
+ warn_report_err(err);
++ err = NULL;
+|
+ warn_reportf_err(err, ...);
++ err = NULL;
+)
+ ... when != err = NULL
+ when != exit(...)
+ fn2(..., err, ...)
+ ...>
+ }