[PATCH] qemu-kvm: fix error handling in msix vector add

Michael S. Tsirkin
2009-07-23T13:35:10Z

When adding a vector fails, the used counter should
not be incremented, otherwise on vector change we will
try to update the routing entry.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/msix.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/hw/msix.c b/hw/msix.c
index 5f77dc9..47cbdc7 100644
--- a/hw/msix.c
+++ b/hw/msix.c
@@ -502,13 +502,19 @@ void msix_reset(PCIDevice *dev)
/* Mark vector as used. */
int msix_vector_use(PCIDevice *dev, unsigned vector)
{
+ int ret;
if (vector >= dev->msix_entries_nr)
return -EINVAL;
- if (dev->msix_entry_used[vector]++)
+ if (dev->msix_entry_used[vector]) {
return 0;
+ }
if (kvm_enabled() && qemu_kvm_irqchip_in_kernel()) {
- return kvm_msix_add(dev, vector);
+ ret = kvm_msix_add(dev, vector);
+ if (ret) {
+ return ret;
+ }
}
+ ++dev->msix_entry_used[vector];
return 0;
}

--
1.6.2.5