diff options
author | Vladimir Sementsov-Ogievskiy | 2020-03-24 16:36:30 +0100 |
---|---|---|
committer | Markus Armbruster | 2020-04-04 14:15:24 +0200 |
commit | 6a4a38530e70f3917a58d71d4d08e28bd8146015 (patch) | |
tree | 760bc12e74b1c1efb0c829c6f24a6a1b232b7dd0 | |
parent | dump/win_dump: fix use after free of err (diff) | |
download | qemu-6a4a38530e70f3917a58d71d4d08e28bd8146015.tar.gz qemu-6a4a38530e70f3917a58d71d4d08e28bd8146015.tar.xz qemu-6a4a38530e70f3917a58d71d4d08e28bd8146015.zip |
qga/commands-posix: fix use after free of local_err
local_err is used several times in guest_suspend(). Setting non-NULL
local_err will crash, so let's zero it after freeing. Also fix possible
leak of local_err in final if().
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20200324153630.11882-7-vsementsov@virtuozzo.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
-rw-r--r-- | qga/commands-posix.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 93474ff770..cc69b82704 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -1773,6 +1773,7 @@ static void guest_suspend(SuspendMode mode, Error **errp) } error_free(local_err); + local_err = NULL; if (pmutils_supports_mode(mode, &local_err)) { mode_supported = true; @@ -1784,6 +1785,7 @@ static void guest_suspend(SuspendMode mode, Error **errp) } error_free(local_err); + local_err = NULL; if (linux_sys_state_supports_mode(mode, &local_err)) { mode_supported = true; @@ -1791,6 +1793,7 @@ static void guest_suspend(SuspendMode mode, Error **errp) } if (!mode_supported) { + error_free(local_err); error_setg(errp, "the requested suspend mode is not supported by the guest"); } else { |