From: Michael S. Tsirkin <[email protected]>

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 <[email protected]>
Signed-off-by: Avi Kivity <[email protected]>

diff --git a/hw/msix.c b/hw/msix.c
index 974268d..b6c3f17 100644
--- a/hw/msix.c
+++ b/hw/msix.c
@@ -503,13 +503,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;
 }
 
--
To unsubscribe from this list: send the line "unsubscribe kvm-commits" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to