Skip to content

Commit

Permalink
qga/commands-posix: fix use after free of local_err
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Vladimir Sementsov-Ogievskiy authored and Markus Armbruster committed Apr 4, 2020
1 parent b0e7095 commit 6a4a385
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions qga/commands-posix.c
Expand Up @@ -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;
Expand All @@ -1784,13 +1785,15 @@ 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;
linux_sys_state_suspend(mode, &local_err);
}

if (!mode_supported) {
error_free(local_err);
error_setg(errp,
"the requested suspend mode is not supported by the guest");
} else {
Expand Down

0 comments on commit 6a4a385

Please sign in to comment.