If we'd fail to enter or exit the monitor the saved error would be
leaked. Introduced in 8498a1e2221 .
Pointed out by coverity.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_hotplug.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index fe703ab4bd..1488f0a7c2 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -354,22 +354,26 @@ qemuHotplugRemoveManagedPR(virQEMUDriverPtr driver,
{
qemuDomainObjPrivatePtr priv = vm->privateData;
virErrorPtr orig_err;
- virErrorPreserveLast(&orig_err);
+ int ret = -1;
if (!priv->prDaemonRunning ||
virDomainDefHasManagedPR(vm->def))
return 0;
+ virErrorPreserveLast(&orig_err);
+
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
- return -1;
+ goto cleanup;
ignore_value(qemuMonitorDelObject(priv->mon, qemuDomainGetManagedPRAlias()));
if (qemuDomainObjExitMonitor(driver, vm) < 0)
- return -1;
+ goto cleanup;
qemuProcessKillManagedPRDaemon(vm);
- virErrorRestore(&orig_err);
- return 0;
+ ret = 0;
+ cleanup:
+ virErrorRestore(&orig_err);
+ return ret;
}
--
2.16.2