conf: Fix error flow in virDomainPCIAddressEnsureAddr()

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: f183b87fc1
Spotted-by: Coverity
Reported-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Andrea Bolognani 2018-11-16 15:04:07 +01:00
parent b3a3759b62
commit 9f4abfa601

View File

@ -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);