[PATCH 3/3] qemu_validate: Fix how qemuValidateDomainDeviceDefZPCIAddress() is called

Michal Privoznik posted 3 patches 5 years, 7 months ago
[PATCH 3/3] qemu_validate: Fix how qemuValidateDomainDeviceDefZPCIAddress() is called
Posted by Michal Privoznik 5 years, 7 months ago
To make the code future proof, the rest of the
qemuValidateDomainDeviceDefAddress() has to be executed (even
though there is nothing there yet) instead of returning directly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/qemu/qemu_validate.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index 2d3a2ec93a..ed1497c425 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -1063,7 +1063,8 @@ qemuValidateDomainDeviceDefAddress(const virDomainDeviceDef *dev,
 
     switch ((virDomainDeviceAddressType) info->type) {
     case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI:
-        return qemuValidateDomainDeviceDefZPCIAddress(info, qemuCaps);
+        if (qemuValidateDomainDeviceDefZPCIAddress(info, qemuCaps) < 0)
+            return -1;
 
     case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE:
         /* Address validation might happen before we have had a chance to
-- 
2.26.2

Re: [PATCH 3/3] qemu_validate: Fix how qemuValidateDomainDeviceDefZPCIAddress() is called
Posted by Andrea Bolognani 5 years, 7 months ago
On Mon, 2020-06-29 at 09:43 +0200, Michal Privoznik wrote:
> +++ b/src/qemu/qemu_validate.c
> @@ -1063,7 +1063,8 @@ qemuValidateDomainDeviceDefAddress(const virDomainDeviceDef *dev,
>  
>      switch ((virDomainDeviceAddressType) info->type) {
>      case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI:
> -        return qemuValidateDomainDeviceDefZPCIAddress(info, qemuCaps);
> +        if (qemuValidateDomainDeviceDefZPCIAddress(info, qemuCaps) < 0)
> +            return -1;

There needs to be a 'break' after the 'if', otherwise on success this
case will fall through to the next case, which is not what we want.

With that added,

  Reviewed-by: Andrea Bolognani <abologna@redhat.com>

and safe for freeze.

-- 
Andrea Bolognani / Red Hat / Virtualization