From: Michal Privoznik <mpriv...@redhat.com> Inside to qemu_tpm.c there are three functions that use the same pattern (qemuTPMEmulatorRunSetup(), qemuTPMEmulatorReconfigure() and qemuTPMEmulatorUpdateProfileName()):
int exitstatus; ... if (virCommandRun(cmd, &exitstatus) < 0 || exitstatus != 0) { virReportError(..., exitstatus); return -1; } Problem with this pattern is that if virCommandRun() fails then exitstatus is left untouched and a garbage value is then passed to virReportError(). Signed-off-by: Michal Privoznik <mpriv...@redhat.com> --- src/qemu/qemu_tpm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index b2f76e6b8b..5ff08fccad 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -439,7 +439,7 @@ qemuTPMEmulatorRunSetup(const virDomainTPMEmulatorDef *emulator, bool incomingMigration) { g_autoptr(virCommand) cmd = NULL; - int exitstatus; + int exitstatus = -1; char uuid[VIR_UUID_STRING_BUFLEN]; g_autofree char *vmid = NULL; g_autofree char *swtpm_setup = virTPMGetSwtpmSetup(); @@ -547,7 +547,7 @@ qemuTPMEmulatorReconfigure(const virDomainTPMEmulatorDef *emulator, const unsigned char *secretuuid) { g_autoptr(virCommand) cmd = NULL; - int exitstatus; + int exitstatus = -1; g_autofree char *activePcrBanksStr = NULL; g_autofree char *swtpm_setup = virTPMGetSwtpmSetup(); g_autofree char *tpm_state = qemuTPMGetSwtpmSetupStateArg(emulator->source_type, @@ -670,7 +670,7 @@ qemuTPMEmulatorUpdateProfileName(virDomainTPMEmulatorDef *emulator, g_autofree char *swtpm = NULL; virJSONValue *active_profile; const char *profile_name; - int exitstatus; + int exitstatus = -1; if (emulator->version != VIR_DOMAIN_TPM_VERSION_2_0 || !virTPMSwtpmCapsGet(VIR_TPM_SWTPM_FEATURE_CMDARG_PRINT_INFO)) -- 2.49.1