[libvirt] [PATCH] qemu: hotplug: Don't leak saved error on failure in qemuHotplugRemoveManagedPR

Peter Krempa posted 1 patch 5 years, 9 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/8ab81796a25b9570f16219e63df073f01dcaf188.1532353277.git.pkrempa@redhat.com
Test syntax-check passed
src/qemu/qemu_hotplug.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
[libvirt] [PATCH] qemu: hotplug: Don't leak saved error on failure in qemuHotplugRemoveManagedPR
Posted by Peter Krempa 5 years, 9 months ago
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>
---
 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

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: hotplug: Don't leak saved error on failure in qemuHotplugRemoveManagedPR
Posted by John Ferlan 5 years, 9 months ago

On 07/23/2018 09:41 AM, Peter Krempa wrote:
> 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>
> ---
>  src/qemu/qemu_hotplug.c | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
> 

Tks -

Reviewed-by: John Ferlan <jferlan@redhat.com>

John

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list