aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2023-04-10 11:47:40 +0100
committerPeter Maydell <peter.maydell@linaro.org>2023-04-10 11:47:40 +0100
commit64f1c63d87208e28e8e38c4ab514ada1728960ef (patch)
tree6a00276285a5289133367ca0b4e0de6871590adb
parentc6f3cbca32bde9ee94d9949aa63e8a7ef2d7bc5b (diff)
parentcc40b8b8448de351f0d15412f20d428712b2e207 (diff)
Merge tag 'pull_error_handle_fix_use_after_free.v1' of https://github.com/stefanberger/qemu-tpm into staging
Fix use-after-free in util/error.c # -----BEGIN PGP SIGNATURE----- # # iQEzBAABCAAdFiEEuBi5yt+QicLVzsZrda1lgCoLQhEFAmQu9xYACgkQda1lgCoL # QhFX2ggAnZZF2KgvVSRh67X+3VdVsg+ifFc/k7kMq74UhTr4lXojPCcgSPu8PaRZ # Mv0I+xNv9pjEU7frwi6vc9DXyhWrVTLgW4TugVBgsB75CnjvFN3lw3T9goCc1h4m # eO7c6SMdUpyQG7ar1mqt2m0bjVz85OAsNYBiAjxfyrKzX6B/mHyru5re/8VC3Hho # IJWGlS51IxrVq44qjB8Lh3voXiEru7dX/y86fWqAiy61pON6+A43rBDIb9JOVv8q # QiHqXVjs9/ax9ZNRudlgJ7bAlUFp6vD9xBm6ztlABI9MCYZeibU6jPMLCBYnGiJq # f//Sqqd4WsqnhOJOLYeMNfFMElIXEw== # =uu4l # -----END PGP SIGNATURE----- # gpg: Signature made Thu 06 Apr 2023 17:45:10 BST # gpg: using RSA key B818B9CADF9089C2D5CEC66B75AD65802A0B4211 # gpg: Good signature from "Stefan Berger <stefanb@linux.vnet.ibm.com>" [unknown] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: B818 B9CA DF90 89C2 D5CE C66B 75AD 6580 2A0B 4211 * tag 'pull_error_handle_fix_use_after_free.v1' of https://github.com/stefanberger/qemu-tpm: util/error: Fix use-after-free errors reported by Coverity Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--util/error.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/util/error.c b/util/error.c
index 5537245da6..e5e247209a 100644
--- a/util/error.c
+++ b/util/error.c
@@ -46,6 +46,10 @@ static void error_handle(Error **errp, Error *err)
}
if (errp == &error_warn) {
warn_report_err(err);
+ } else if (errp && !*errp) {
+ *errp = err;
+ } else {
+ error_free(err);
}
}
@@ -76,7 +80,6 @@ static void error_setv(Error **errp,
err->func = func;
error_handle(errp, err);
- *errp = err;
errno = saved_errno;
}
@@ -289,11 +292,6 @@ void error_propagate(Error **dst_errp, Error *local_err)
return;
}
error_handle(dst_errp, local_err);
- if (dst_errp && !*dst_errp) {
- *dst_errp = local_err;
- } else {
- error_free(local_err);
- }
}
void error_propagate_prepend(Error **dst_errp, Error *err,