Re: [PATCH v1 01/10] qemu_driver.c: use g_autoptr() with virDomainDef pointers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 11/13/20 2:39 PM, John Ferlan wrote:

Coverity found a bad merge conflict resolution...


Thanks John. Just posted a fix. Guess I'll have to find a way to
run Coverity before pushing stuff ...


DHB



On 11/12/20 4:48 PM, Daniel Henrique Barboza wrote:
Signed-off-by: Daniel Henrique Barboza <danielhb413@xxxxxxxxx>
---
  src/qemu/qemu_driver.c | 54 ++++++++++++++----------------------------
  1 file changed, 18 insertions(+), 36 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 05f8eb2cb7..fdbac9d21d 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c

[...]

          ret = -1;
@@ -6689,8 +6682,8 @@ qemuDomainDefineXMLFlags(virConnectPtr conn,
                           unsigned int flags)
  {
      virQEMUDriverPtr driver = conn->privateData;
-    virDomainDefPtr def = NULL;
-    virDomainDefPtr oldDef = NULL;
+    g_autoptr(virDomainDef) def = NULL;
+    g_autoptr(virDomainDef) oldDef = NULL;
      virDomainObjPtr vm = NULL;
      virDomainPtr dom = NULL;
      virObjectEventPtr event = NULL;
@@ -6751,8 +6744,6 @@ qemuDomainDefineXMLFlags(virConnectPtr conn,
      dom = virGetDomain(conn, vm->def->name, vm->def->uuid, vm->def->id);
cleanup:
-    virDomainDefFree(oldDef);
-    virDomainDefFree(def);
      virDomainObjEndAPI(&vm);
      virObjectEventStateQueue(driver->domainEventState, event);
      return dom;
@@ -7755,7 +7746,7 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr vm,

The code that was pushed added:

+
+    event = virDomainEventLifecycleNewFromObj(vm,
+                                     VIR_DOMAIN_EVENT_DEFINED,
+                                     !oldDef ?
+                                     VIR_DOMAIN_EVENT_DEFINED_ADDED :
+                                     VIR_DOMAIN_EVENT_DEFINED_UPDATED);
+
+    VIR_INFO("Creating domain '%s'", vm->def->name);
+    dom = virGetDomain(conn, vm->def->name, vm->def->uuid, vm->def->id);
+

within the cleanup: label even though recent commit 773c7c43611 had
moved the code up higher.

The coverity error is that @event gets overwritten...

Hopefully easy enough to figure out.

John
[...]





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux