[libvirt] [PATCH 0/2] Fix a couple of recently found coverity issues

John Ferlan (2): qemu: Remove dead code lxc: Fix lxcDomainDestroyFlags endjob processing src/lxc/lxc_driver.c | 8 ++++---- src/qemu/qemu_domain_address.c | 14 +++++--------- 2 files changed, 9 insertions(+), 13 deletions(-) -- 2.5.5

Since commit id '20a0fa8e' removed the QEMU_CAPS_DEVICE, Coverity notes that it's no longer possible to have 'addrs' be NULL when checking for a live domain since qemuDomainPCIAddressSetCreate would have jumped to cleanup if addrs was NULL. Signed-off-by: John Ferlan <jferlan@redhat.com> --- src/qemu/qemu_domain_address.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 9d09b3a..0a92b0e 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -1618,15 +1618,11 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def, if (obj && obj->privateData) { priv = obj->privateData; - if (addrs) { - /* if this is the live domain object, we persist the PCI addresses*/ - virDomainPCIAddressSetFree(priv->pciaddrs); - priv->persistentAddrs = 1; - priv->pciaddrs = addrs; - addrs = NULL; - } else { - priv->persistentAddrs = 0; - } + /* if this is the live domain object, we persist the PCI addresses*/ + virDomainPCIAddressSetFree(priv->pciaddrs); + priv->persistentAddrs = 1; + priv->pciaddrs = addrs; + addrs = NULL; } ret = 0; -- 2.5.5

On Fri, May 20, 2016 at 10:21:47AM -0400, John Ferlan wrote:
Since commit id '20a0fa8e' removed the QEMU_CAPS_DEVICE, Coverity notes that it's no longer possible to have 'addrs' be NULL when checking for a live domain since qemuDomainPCIAddressSetCreate would have jumped to cleanup if addrs was NULL.
Signed-off-by: John Ferlan <jferlan@redhat.com> --- src/qemu/qemu_domain_address.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 9d09b3a..0a92b0e 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -1618,15 +1618,11 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
if (obj && obj->privateData) { priv = obj->privateData; - if (addrs) { - /* if this is the live domain object, we persist the PCI addresses*/ - virDomainPCIAddressSetFree(priv->pciaddrs); - priv->persistentAddrs = 1; - priv->pciaddrs = addrs; - addrs = NULL; - } else { - priv->persistentAddrs = 0; - } + /* if this is the live domain object, we persist the PCI addresses*/ + virDomainPCIAddressSetFree(priv->pciaddrs); + priv->persistentAddrs = 1;
The whole persistentAddrs variable has not been used in years and can be dropped: https://www.redhat.com/archives/libvir-list/2016-May/msg01575.html Jan
+ priv->pciaddrs = addrs; + addrs = NULL; }
ret = 0; -- 2.5.5
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

Commit id '15ccb0dbf' added job functions for the lxc driver; however, for shutdown and nonpersistent path, the vm was removed from the domain object list and the vm pointer cleared before the endjob. Adjust the code to perform the endjob first and then perform the ObjListRemove as long as the vm wasn't NULL. This follows more closely models from qemu and libxl Found by Coverity (FORWARD_NULL) Signed-off-by: John Ferlan <jferlan@redhat.com> --- src/lxc/lxc_driver.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 7cdea2c..1f45d38 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1562,16 +1562,16 @@ lxcDomainDestroyFlags(virDomainPtr dom, VIR_DOMAIN_EVENT_STOPPED_DESTROYED); priv->doneStopEvent = true; virDomainAuditStop(vm, "destroyed"); - if (!vm->persistent) { - virDomainObjListRemove(driver->domains, vm); - vm = NULL; - } endjob: if (!virLXCDomainObjEndJob(driver, vm)) vm = NULL; cleanup: + if (vm && !vm->persistent) { + virDomainObjListRemove(driver->domains, vm); + vm = NULL; + } if (vm) virObjectUnlock(vm); if (event) -- 2.5.5

On 20/05/16 16:21, John Ferlan wrote:
John Ferlan (2): qemu: Remove dead code lxc: Fix lxcDomainDestroyFlags endjob processing
src/lxc/lxc_driver.c | 8 ++++---- src/qemu/qemu_domain_address.c | 14 +++++--------- 2 files changed, 9 insertions(+), 13 deletions(-)
ACK series Erik
participants (3)
-
Erik Skultety
-
John Ferlan
-
Ján Tomko