]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: hotplug: Don't leak saved error on failure in qemuHotplugRemoveManagedPR
authorPeter Krempa <pkrempa@redhat.com>
Mon, 23 Jul 2018 13:38:02 +0000 (15:38 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 24 Jul 2018 08:20:32 +0000 (10:20 +0200)
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@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/qemu/qemu_hotplug.c

index fe703ab4bdeddf7e727776177e141ca900e45d63..1488f0a7c269bb5b14546658cc48dade0815c38c 100644 (file)
@@ -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;
 }