[PATCH 1/3] conf: Fix error flow in virDomainPCIAddressEnsureAddr()

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

 



This avoids setting 'ret' multiple times, which will result
in errors being masked if the first operation fails but the
second one succeeds.

Introduced-by: f183b87fc1dbcc6446ac3c1cef9cdd345b9725fb
Spotted-by: Coverity
Reported-by: John Ferlan <jferlan@xxxxxxxxxx>
Signed-off-by: Andrea Bolognani <abologna@xxxxxxxxxx>
---
 src/conf/domain_addr.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index 3e1d767e4f..cc9ea82a33 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -940,15 +940,21 @@ virDomainPCIAddressEnsureAddr(virDomainPCIAddressSetPtr addrs,
                                          addrStr, flags, true))
             goto cleanup;
 
-        ret = virDomainPCIAddressReserveAddrInternal(addrs, &dev->addr.pci,
-                                                     flags, dev->isolationGroup,
-                                                     true);
+        if (virDomainPCIAddressReserveAddrInternal(addrs, &dev->addr.pci,
+                                                   flags, dev->isolationGroup,
+                                                   true) < 0) {
+            goto cleanup;
+        }
     } else {
-        ret = virDomainPCIAddressReserveNextAddr(addrs, dev, flags, -1);
+        if (virDomainPCIAddressReserveNextAddr(addrs, dev, flags, -1) < 0)
+            goto cleanup;
     }
 
     dev->addr.pci.extFlags = dev->pciAddrExtFlags;
-    ret = virDomainPCIAddressExtensionEnsureAddr(addrs, &dev->addr.pci);
+    if (virDomainPCIAddressExtensionEnsureAddr(addrs, &dev->addr.pci) < 0)
+        goto cleanup;
+
+    ret = 0;
 
  cleanup:
     VIR_FREE(addrStr);
-- 
2.19.1

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



[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